Date: Sun, 11 Jul 2004 01:53:24 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 57027 for review Message-ID: <200407110153.i6B1rOKK051885@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=57027 Change 57027 by marcel@marcel_nfs on 2004/07/11 01:52:31 IFC @57026 Affected files ... .. //depot/projects/gdb/sys/compat/ndis/kern_ndis.c#16 integrate .. //depot/projects/gdb/sys/compat/ndis/ndis_var.h#8 integrate .. //depot/projects/gdb/sys/compat/ndis/subr_ndis.c#13 integrate .. //depot/projects/gdb/sys/conf/NOTES#32 integrate .. //depot/projects/gdb/sys/conf/files.powerpc#4 integrate .. //depot/projects/gdb/sys/conf/options#31 integrate .. //depot/projects/gdb/sys/dev/if_ndis/if_ndis_pccard.c#6 integrate .. //depot/projects/gdb/sys/dev/if_ndis/if_ndis_pci.c#6 integrate .. //depot/projects/gdb/sys/dev/if_ndis/if_ndisvar.h#7 integrate .. //depot/projects/gdb/sys/kern/uipc_socket.c#21 integrate .. //depot/projects/gdb/usr.bin/hexdump/conv.c#2 integrate .. //depot/projects/gdb/usr.bin/hexdump/display.c#2 integrate .. //depot/projects/gdb/usr.bin/hexdump/hexdump.h#2 integrate .. //depot/projects/gdb/usr.bin/hexdump/od.1#3 integrate Differences ... ==== //depot/projects/gdb/sys/compat/ndis/kern_ndis.c#16 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.56 2004/06/07 01:22:48 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.57 2004/07/11 00:19:30 wpaul Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -853,7 +853,8 @@ rl->cprl_count = sc->ndis_rescnt; prd = rl->cprl_partial_descs; - brl = BUS_GET_RESOURCE_LIST(device_get_parent(dev), dev); + brl = BUS_GET_RESOURCE_LIST(dev, dev); + if (brl != NULL) { /* ==== //depot/projects/gdb/sys/compat/ndis/ndis_var.h#8 (text+ko) ==== @@ -29,7 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/ndis/ndis_var.h,v 1.26 2004/07/07 17:46:29 wpaul Exp $ + * $FreeBSD: src/sys/compat/ndis/ndis_var.h,v 1.27 2004/07/11 00:19:30 wpaul Exp $ */ #ifndef _NDIS_VAR_H_ @@ -1500,6 +1500,7 @@ extern int ndis_send_packet(void *, ndis_packet *); extern int ndis_convert_res(void *); extern int ndis_alloc_amem(void *); +extern void ndis_free_amem(void *); extern void ndis_free_packet(ndis_packet *); extern void ndis_free_bufs(ndis_buffer *); extern int ndis_reset_nic(void *); @@ -1520,6 +1521,7 @@ extern int ndis_unsched(void (*)(void *), void *, int); extern int ndis_thsuspend(struct proc *, int); extern void ndis_thresume(struct proc *); +extern int ndis_strcasecmp(const char *, const char *); __END_DECLS #endif /* _NDIS_VAR_H_ */ ==== //depot/projects/gdb/sys/compat/ndis/subr_ndis.c#13 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.61 2004/07/07 17:46:29 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.62 2004/07/11 00:19:30 wpaul Exp $"); /* * This file implements a translation layer between the BSD networking @@ -130,7 +130,6 @@ struct sysctl_oid *, ndis_parm_type, ndis_config_parm **); static ndis_status ndis_decode_parm(ndis_miniport_block *, ndis_config_parm *, char *); -static int my_strcasecmp(const char *, const char *); __stdcall static void ndis_read_cfg(ndis_status *, ndis_config_parm **, ndis_handle, ndis_unicode_string *, ndis_parm_type); __stdcall static void ndis_write_cfg(ndis_status *, ndis_handle, @@ -556,8 +555,8 @@ return(NDIS_STATUS_SUCCESS); } -static int -my_strcasecmp(s1, s2) +int +ndis_strcasecmp(s1, s2) const char *s1; const char *s2; { @@ -619,7 +618,7 @@ TAILQ_FOREACH(e, device_get_sysctl_ctx(sc->ndis_dev), link) { #endif oidp = e->entry; - if (my_strcasecmp(oidp->oid_name, keystr) == 0) { + if (ndis_strcasecmp(oidp->oid_name, keystr) == 0) { if (strcmp((char *)oidp->oid_arg1, "UNSET") == 0) { free(keystr, M_DEVBUF); *status = NDIS_STATUS_FAILURE; @@ -719,7 +718,7 @@ TAILQ_FOREACH(e, device_get_sysctl_ctx(sc->ndis_dev), link) { #endif oidp = e->entry; - if (my_strcasecmp(oidp->oid_name, keystr) == 0) { + if (ndis_strcasecmp(oidp->oid_name, keystr) == 0) { /* Found it, set the value. */ strcpy((char *)oidp->oid_arg1, val); free(keystr, M_DEVBUF); @@ -885,6 +884,7 @@ uint16_t flags; char msgbuf[ERRMSGLEN]; + block = (ndis_miniport_block *)adapter; error = pe_get_message(block->nmb_img, code, &str, &i, &flags); @@ -1478,6 +1478,9 @@ else if (sc->ndis_res_altmem != NULL && paddr.np_quad == rman_get_start(sc->ndis_res_altmem)) *vaddr = (void *)rman_get_virtual(sc->ndis_res_altmem); + else if (sc->ndis_res_am != NULL && + paddr.np_quad == rman_get_start(sc->ndis_res_am)) + *vaddr = (void *)rman_get_virtual(sc->ndis_res_am); else return(NDIS_STATUS_FAILURE); @@ -2244,7 +2247,7 @@ bt = rman_get_bustag(sc->ndis_res_am); for (i = 0; i < len; i++) - dest[i] = bus_space_read_1(bt, bh, (offset * 2) + (i * 2)); + dest[i] = bus_space_read_1(bt, bh, (offset + i) * 2); return(i); } @@ -2274,7 +2277,7 @@ bt = rman_get_bustag(sc->ndis_res_am); for (i = 0; i < len; i++) - bus_space_write_1(bt, bh, (offset * 2) + (i * 2), src[i]); + bus_space_write_1(bt, bh, (offset + i) * 2, src[i]); return(i); } @@ -2584,7 +2587,7 @@ NDFREE(&nd, NDF_ONLY_PNBUF); /* Get the file size. */ - VOP_GETATTR(nd.ni_vp, vap, NOCRED, td); + VOP_GETATTR(nd.ni_vp, vap, td->td_ucred, td); VOP_UNLOCK(nd.ni_vp, 0, td); mtx_unlock(&Giant); @@ -2593,6 +2596,7 @@ *filehandle = fh; *filelength = fh->nf_maplen = vap->va_size & 0xFFFFFFFF; *status = NDIS_STATUS_SUCCESS; + return; } ==== //depot/projects/gdb/sys/conf/NOTES#32 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1243 2004/07/08 22:35:34 brian Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1244 2004/07/11 01:44:07 marcel Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # ==== //depot/projects/gdb/sys/conf/files.powerpc#4 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.powerpc,v 1.37 2004/03/23 18:26:02 alc Exp $ +# $FreeBSD: src/sys/conf/files.powerpc,v 1.38 2004/07/11 01:38:25 grehan Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -27,6 +27,7 @@ dev/syscons/syscons.c optional sc dev/syscons/sysmouse.c optional sc geom/geom_apple.c standard +kern/syscalls.c optional ktr powerpc/powerpc/atomic.S standard powerpc/powerpc/autoconf.c standard powerpc/powerpc/bcopy.c standard ==== //depot/projects/gdb/sys/conf/options#31 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/options,v 1.463 2004/07/10 19:34:06 marcel Exp $ +# $FreeBSD: src/sys/conf/options,v 1.464 2004/07/11 01:44:07 marcel Exp $ # # On the handling of kernel options # @@ -30,15 +30,6 @@ # If filename is missing, the default is # opt_<name-of-option-in-lower-case>.h -# XXX temporary -GDB -KDB opt_global.h -KDB_TRACE opt_kdb.h -KDB_UNATTENDED opt_kdb.h -WITNESS_KDB opt_witness.h -SC_DISABLE_KDBKEY opt_syscons.h - - AAC_DEBUG opt_aac.h AHC_ALLOW_MEMIO opt_aic7xxx.h AHC_TMODE_ENABLE opt_aic7xxx.h ==== //depot/projects/gdb/sys/dev/if_ndis/if_ndis_pccard.c#6 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis_pccard.c,v 1.5 2004/06/01 23:27:36 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis_pccard.c,v 1.6 2004/07/11 00:19:30 wpaul Exp $"); #include <sys/ctype.h> #include <sys/param.h> @@ -85,14 +85,14 @@ static int ndis_probe_pccard (device_t); static int ndis_attach_pccard (device_t); +static struct resource_list *ndis_get_resource_list + (device_t, device_t); extern int ndis_attach (device_t); extern int ndis_shutdown (device_t); extern int ndis_detach (device_t); extern int ndis_suspend (device_t); extern int ndis_resume (device_t); -static int my_strcasecmp (const char *, const char *, int); - extern struct mtx_pool *ndis_mtxpool; static device_method_t ndis_methods[] = { @@ -104,6 +104,15 @@ DEVMETHOD(device_suspend, ndis_suspend), DEVMETHOD(device_resume, ndis_resume), + /* Bus interface. */ + + /* + * This is an awful kludge, but we need it becase pccard + * does not implement a bus_get_resource_list() method. + */ + + DEVMETHOD(bus_get_resource_list, ndis_get_resource_list), + { 0, 0 } }; @@ -127,22 +136,6 @@ DRIVER_MODULE(ndis, pccard, ndis_driver, ndis_devclass, 0, 0); #endif -static int my_strcasecmp(s1, s2, len) - const char *s1; - const char *s2; - int len; -{ - int i; - - for (i = 0; i < len; i++) { - if (toupper(s1[i]) != toupper(s2[i])) - return(0); - } - - return(1); -} - - /* * Probe for an NDIS device. Check the PCI vendor and device * IDs against our list and return a device name if we find a match. @@ -165,8 +158,8 @@ return(error); while(t->ndis_name != NULL) { - if (my_strcasecmp(vendstr, t->ndis_vid, strlen(vendstr)) && - my_strcasecmp(prodstr, t->ndis_did, strlen(prodstr))) { + if (ndis_strcasecmp(vendstr, t->ndis_vid) == 0 && + ndis_strcasecmp(prodstr, t->ndis_did) == 0) { device_set_desc(dev, t->ndis_name); return(0); } @@ -193,6 +186,7 @@ sc = device_get_softc(dev); unit = device_get_unit(dev); sc->ndis_dev = dev; + resource_list_init(&sc->ndis_rl); sc->ndis_io_rid = 0; sc->ndis_res_io = bus_alloc_resource(dev, @@ -205,6 +199,9 @@ goto fail; } sc->ndis_rescnt++; + resource_list_add(&sc->ndis_rl, SYS_RES_IOPORT, rid, + rman_get_start(sc->ndis_res_io), rman_get_end(sc->ndis_res_io), + rman_get_size(sc->ndis_res_io)); rid = 0; sc->ndis_irq = bus_alloc_resource(dev, @@ -217,6 +214,8 @@ goto fail; } sc->ndis_rescnt++; + resource_list_add(&sc->ndis_rl, SYS_RES_IRQ, rid, + rman_get_start(sc->ndis_irq), rman_get_start(sc->ndis_irq), 1); sc->ndis_iftype = PCMCIABus; @@ -232,8 +231,8 @@ return(error); while(t->ndis_name != NULL) { - if (my_strcasecmp(vendstr, t->ndis_vid, strlen(vendstr)) && - my_strcasecmp(prodstr, t->ndis_did, strlen(prodstr))) + if (ndis_strcasecmp(vendstr, t->ndis_vid) == 0 && + ndis_strcasecmp(prodstr, t->ndis_did) == 0) break; t++; devidx++; @@ -247,6 +246,17 @@ return(error); } +static struct resource_list * +ndis_get_resource_list(dev, child) + device_t dev; + device_t child; +{ + struct ndis_softc *sc; + + sc = device_get_softc(dev); + return (&sc->ndis_rl); +} + #endif /* NDIS_PCI_DEV_TABLE */ #define NDIS_AM_RID 3 @@ -271,6 +281,10 @@ "failed to allocate attribute memory\n"); return(ENXIO); } + sc->ndis_rescnt++; + resource_list_add(&sc->ndis_rl, SYS_RES_MEMORY, rid, + rman_get_start(sc->ndis_res_am), rman_get_end(sc->ndis_res_am), + rman_get_size(sc->ndis_res_am)); error = CARD_SET_MEMORY_OFFSET(device_get_parent(sc->ndis_dev), sc->ndis_dev, rid, 0, NULL); @@ -290,5 +304,26 @@ return(error); } + sc->ndis_am_rid = rid; + return(0); } + +void +ndis_free_amem(arg) + void *arg; +{ + struct ndis_softc *sc; + + if (arg == NULL) + return; + + sc = arg; + + if (sc->ndis_res_am != NULL) + bus_release_resource(sc->ndis_dev, SYS_RES_MEMORY, + sc->ndis_am_rid, sc->ndis_res_am); + resource_list_free(&sc->ndis_rl); + + return; +} ==== //depot/projects/gdb/sys/dev/if_ndis/if_ndis_pci.c#6 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis_pci.c,v 1.6 2004/06/01 23:27:36 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis_pci.c,v 1.7 2004/07/11 00:19:30 wpaul Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -84,6 +84,8 @@ static int ndis_probe_pci (device_t); static int ndis_attach_pci (device_t); +static struct resource_list *ndis_get_resource_list + (device_t, device_t); extern int ndis_attach (device_t); extern int ndis_shutdown (device_t); extern int ndis_detach (device_t); @@ -101,6 +103,9 @@ DEVMETHOD(device_suspend, ndis_suspend), DEVMETHOD(device_resume, ndis_resume), + /* Bus interface */ + DEVMETHOD(bus_get_resource_list, ndis_get_resource_list), + { 0, 0 } }; @@ -321,4 +326,15 @@ return(error); } +static struct resource_list * +ndis_get_resource_list(dev, child) + device_t dev; + device_t child; +{ + struct ndis_softc *sc; + + sc = device_get_softc(dev); + return (BUS_GET_RESOURCE_LIST(device_get_parent(sc->ndis_dev), dev)); +} + #endif /* NDIS_PCI_DEV_TABLE */ ==== //depot/projects/gdb/sys/dev/if_ndis/if_ndisvar.h#7 (text+ko) ==== @@ -29,7 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/if_ndis/if_ndisvar.h,v 1.14 2004/07/07 17:46:30 wpaul Exp $ + * $FreeBSD: src/sys/dev/if_ndis/if_ndisvar.h,v 1.15 2004/07/11 00:19:30 wpaul Exp $ */ #define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node" @@ -90,7 +90,9 @@ struct resource *ndis_res_altmem; int ndis_altmem_rid; struct resource *ndis_res_am; /* attribute mem (pccard) */ + int ndis_am_rid; struct resource *ndis_res_cm; /* common mem (pccard) */ + struct resource_list ndis_rl; int ndis_rescnt; struct mtx ndis_mtx; struct mtx ndis_intrmtx; ==== //depot/projects/gdb/sys/kern/uipc_socket.c#21 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.195 2004/07/10 21:43:35 rwatson Exp $"); +__FBSDID("$FreeBSD: src/sys/kern/uipc_socket.c,v 1.198 2004/07/11 01:44:12 rwatson Exp $"); #include "opt_inet.h" #include "opt_mac.h" @@ -63,6 +63,9 @@ #include <vm/uma.h> +static int soreceive_rcvoob(struct socket *so, struct uio *uio, + int flags); + #ifdef INET static int do_setopt_accept_filter(struct socket *so, struct sockopt *sopt); #endif @@ -831,6 +834,64 @@ } /* + * The part of soreceive() that implements reading non-inline out-of-band + * data from a socket. For more complete comments, see soreceive(), from + * which this code originated. + * + * XXXRW: Note that soreceive_rcvoob(), unlike the remainder of soreceve(), + * is unable to return an mbuf chain to the caller. + */ +static int +soreceive_rcvoob(so, uio, flags) + struct socket *so; + struct uio *uio; + int flags; +{ + struct protosw *pr = so->so_proto; + struct mbuf *m; + int error; + + KASSERT(flags & MSG_OOB, ("soreceive_rcvoob: (flags & MSG_OOB) == 0")); + + m = m_get(M_TRYWAIT, MT_DATA); + if (m == NULL) + return (ENOBUFS); + error = (*pr->pr_usrreqs->pru_rcvoob)(so, m, flags & MSG_PEEK); + if (error) + goto bad; + do { +#ifdef ZERO_COPY_SOCKETS + if (so_zero_copy_receive) { + vm_page_t pg; + int disposable; + + if ((m->m_flags & M_EXT) + && (m->m_ext.ext_type == EXT_DISPOSABLE)) + disposable = 1; + else + disposable = 0; + + pg = PHYS_TO_VM_PAGE(vtophys(mtod(m, caddr_t))); + if (uio->uio_offset == -1) + uio->uio_offset =IDX_TO_OFF(pg->pindex); + + error = uiomoveco(mtod(m, void *), + min(uio->uio_resid, m->m_len), + uio, pg->object, + disposable); + } else +#endif /* ZERO_COPY_SOCKETS */ + error = uiomove(mtod(m, void *), + (int) min(uio->uio_resid, m->m_len), uio); + m = m_free(m); + } while (uio->uio_resid && error == 0 && m); +bad: + if (m != NULL) + m_freem(m); + return (error); +} + +/* * Implement receive operations on a socket. * We depend on the way that records are added to the sockbuf * by sbappend*. In particular, each record (mbufs linked through m_next) @@ -864,51 +925,15 @@ mp = mp0; if (psa != NULL) - *psa = 0; + *psa = NULL; if (controlp != NULL) - *controlp = 0; + *controlp = NULL; if (flagsp != NULL) flags = *flagsp &~ MSG_EOR; else flags = 0; - if (flags & MSG_OOB) { - m = m_get(M_TRYWAIT, MT_DATA); - if (m == NULL) - return (ENOBUFS); - error = (*pr->pr_usrreqs->pru_rcvoob)(so, m, flags & MSG_PEEK); - if (error) - goto bad; - do { -#ifdef ZERO_COPY_SOCKETS - if (so_zero_copy_receive) { - vm_page_t pg; - int disposable; - - if ((m->m_flags & M_EXT) - && (m->m_ext.ext_type == EXT_DISPOSABLE)) - disposable = 1; - else - disposable = 0; - - pg = PHYS_TO_VM_PAGE(vtophys(mtod(m, caddr_t))); - if (uio->uio_offset == -1) - uio->uio_offset =IDX_TO_OFF(pg->pindex); - - error = uiomoveco(mtod(m, void *), - min(uio->uio_resid, m->m_len), - uio, pg->object, - disposable); - } else -#endif /* ZERO_COPY_SOCKETS */ - error = uiomove(mtod(m, void *), - (int) min(uio->uio_resid, m->m_len), uio); - m = m_free(m); - } while (uio->uio_resid && error == 0 && m); -bad: - if (m != NULL) - m_freem(m); - return (error); - } + if (flags & MSG_OOB) + return (soreceive_rcvoob(so, uio, flags)); if (mp != NULL) *mp = NULL; if (so->so_state & SS_ISCONFIRMING && uio->uio_resid) @@ -985,6 +1010,7 @@ SOCKBUF_LOCK_ASSERT(&so->so_rcv); if (uio->uio_td) uio->uio_td->td_proc->p_stats->p_ru.ru_msgrcv++; + KASSERT(m == so->so_rcv.sb_mb, ("soreceive: m != so->so_rcv.sb_mb")); SBLASTRECORDCHK(&so->so_rcv); SBLASTMBUFCHK(&so->so_rcv); nextrecord = m->m_nextpkt; ==== //depot/projects/gdb/usr.bin/hexdump/conv.c#2 (text+ko) ==== @@ -35,20 +35,35 @@ static const char sccsid[] = "@(#)conv.c 8.1 (Berkeley) 6/6/93"; #endif /* not lint */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/usr.bin/hexdump/conv.c,v 1.6 2002/09/04 23:29:01 dwmalone Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/hexdump/conv.c,v 1.7 2004/07/11 01:11:12 tjr Exp $"); #include <sys/types.h> +#include <assert.h> #include <stdio.h> #include <ctype.h> +#include <limits.h> +#include <stdlib.h> +#include <wchar.h> +#include <wctype.h> #include "hexdump.h" void -conv_c(PR *pr, u_char *p) +conv_c(PR *pr, u_char *p, size_t bufsize) { char buf[10]; char const *str; + wchar_t wc; + size_t clen, oclen; + int converr, pad, width; + char peekbuf[MB_LEN_MAX]; + if (pr->mbleft > 0) { + str = "**"; + pr->mbleft--; + goto strpr; + } + switch(*p) { case '\0': str = "\\0"; @@ -78,9 +93,53 @@ default: break; } - if (isprint(*p)) { - *pr->cchar = 'c'; - (void)printf(pr->fmt, *p); + /* + * Multibyte characters are disabled for hexdump(1) for backwards + * compatibility and consistency (none of its other output formats + * recognize them correctly). + */ + converr = 0; + if (odmode && MB_CUR_MAX > 1) { + oclen = 0; +retry: + clen = mbrtowc(&wc, p, bufsize, &pr->mbstate); + if (clen == 0) + clen = 1; + else if (clen == (size_t)-1 || (clen == (size_t)-2 && + buf == peekbuf)) { + memset(&pr->mbstate, 0, sizeof(pr->mbstate)); + wc = *p; + clen = 1; + converr = 1; + } else if (clen == (size_t)-2) { + /* + * Incomplete character; peek ahead and see if we + * can complete it. + */ + oclen = bufsize; + bufsize = peek(p = peekbuf, MB_CUR_MAX); + goto retry; + } + clen += oclen; + } else { + wc = *p; + clen = 1; + } + if (!converr && iswprint(wc)) { + if (!odmode) { + *pr->cchar = 'c'; + (void)printf(pr->fmt, (int)wc); + } else { + *pr->cchar = 'C'; + assert(strcmp(pr->fmt, "%3C") == 0); + width = wcwidth(wc); + assert(width > 0); + pad = 3 - width; + if (pad < 0) + pad = 0; + (void)printf("%*s%C", pad, "", wc); + pr->mbleft = clen - 1; + } } else { (void)sprintf(buf, "%03o", (int)*p); str = buf; ==== //depot/projects/gdb/usr.bin/hexdump/display.c#2 (text+ko) ==== @@ -37,7 +37,7 @@ #endif #endif /* not lint */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/usr.bin/hexdump/display.c,v 1.18 2002/09/04 23:29:01 dwmalone Exp $"); +__FBSDID("$FreeBSD: src/usr.bin/hexdump/display.c,v 1.19 2004/07/11 01:11:12 tjr Exp $"); #include <sys/param.h> #include <sys/stat.h> @@ -132,7 +132,8 @@ (void)printf(pr->fmt, ""); break; case F_C: - conv_c(pr, bp); + conv_c(pr, bp, eaddress ? eaddress - address : + blocksize - address % blocksize); break; case F_CHAR: (void)printf(pr->fmt, *bp); @@ -261,6 +262,10 @@ errx(1, "cannot skip past end of input"); if (need == blocksize) return((u_char *)NULL); + /* + * XXX bcmp() is not quite right in the presence + * of multibyte characters. + */ if (vflag != ALL && valid_save && bcmp(curp, savp, nread) == 0) { @@ -284,6 +289,10 @@ if (length != -1) length -= n; if (!(need -= n)) { + /* + * XXX bcmp() is not quite right in the presence + * of multibyte characters. + */ if (vflag == ALL || vflag == FIRST || valid_save == 0 || bcmp(curp, savp, blocksize) != 0) { @@ -303,6 +312,27 @@ } } +size_t +peek(u_char *buf, size_t nbytes) +{ + size_t n, nread; + int c; + + if (length != -1 && nbytes > length) + nbytes = length; + nread = 0; + while (nread < nbytes && (c = getchar()) != EOF) { + *buf++ = c; + nread++; + } + n = nread; + while (n-- > 0) { + c = *--buf; + ungetc(c, stdin); + } + return (nread); +} + int next(char **argv) { ==== //depot/projects/gdb/usr.bin/hexdump/hexdump.h#2 (text+ko) ==== @@ -31,9 +31,11 @@ * SUCH DAMAGE. * * @(#)hexdump.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/hexdump/hexdump.h,v 1.8 2002/09/04 23:29:01 dwmalone Exp $ + * $FreeBSD: src/usr.bin/hexdump/hexdump.h,v 1.9 2004/07/11 01:11:12 tjr Exp $ */ +#include <wchar.h> + typedef struct _pr { struct _pr *nextpr; /* next print unit */ #define F_ADDRESS 0x001 /* print offset */ @@ -52,6 +54,8 @@ char *cchar; /* conversion character */ char *fmt; /* printf format */ char *nospace; /* no whitespace version */ + int mbleft; /* bytes left of multibyte char. */ + mbstate_t mbstate; /* conversion state */ } PR; typedef struct _fu { @@ -88,7 +92,7 @@ void badfmt(const char *); void badsfmt(void); void bpad(PR *); -void conv_c(PR *, u_char *); +void conv_c(PR *, u_char *, size_t); void conv_u(PR *, u_char *); void display(void); void doskip(const char *, int); @@ -98,6 +102,7 @@ int next(char **); void nomem(void); void oldsyntax(int, char ***); +size_t peek(u_char *, size_t); void rewrite(FS *); int size(FS *); void usage(void); ==== //depot/projects/gdb/usr.bin/hexdump/od.1#3 (text+ko) ==== @@ -30,9 +30,9 @@ .\" SUCH DAMAGE. .\" .\" @(#)od.1 8.1 (Berkeley) 6/6/93 -.\" $FreeBSD: src/usr.bin/hexdump/od.1,v 1.16 2004/07/03 01:28:20 tjr Exp $ +.\" $FreeBSD: src/usr.bin/hexdump/od.1,v 1.17 2004/07/11 01:11:12 tjr Exp $ .\" -.Dd July 3, 2004 +.Dd July 11, 2004 .Os .Dt OD 1 .Sh NAME @@ -179,6 +179,10 @@ .It vertical tab \ev .El +.Pp +Multi-byte characters are displayed in the area corresponding to the first +byte of the character. The remaining bytes are shown as +.Ql ** . .It Xo .Sm off .Op Cm d | o | u | x @@ -231,6 +235,15 @@ If no output format is specified, .Fl t Ar oS is assumed. +.Sh ENVIRONMENT +The +.Ev LANG , LC_ALL +and +.Ev LC_CTYPE +environment variables affect the execution of +.Nm +as described in +.Xr environ 7 . .Sh DIAGNOSTICS .Ex -std .Sh COMPATIBILITY @@ -252,7 +265,3 @@ .Nm command appeared in .At v1 . -.Sh BUGS -The -.Nm -utility does not recognize multibyte characters.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407110153.i6B1rOKK051885>