Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!ukc!eagle!icdoc!cl-jenny!am From: am@cl.cam.ac.uk (Alan Mycroft) Newsgroups: comp.arch,comp.lang.c Subject: Re: String Processing Instruction Message-ID: <699@jenny.cl.cam.ac.uk> Date: Mon, 27-Apr-87 07:31:14 EDT Article-I.D.: jenny.699 Posted: Mon Apr 27 07:31:14 1987 Date-Received: Sun, 3-May-87 00:50:14 EDT References: <15292@amdcad.UUCP> <693@jenny.cl.cam.ac.uk> <7349@boring.mcvax.cwi.nl> <4605@utcsri.UUCP> Reply-To: am@cl.cam.ac.uk (Alan Mycroft) Organization: U of Cambridge Comp Lab, UK Lines: 12 Xref: mnetor comp.arch:1152 comp.lang.c:2013 In article <4605@utcsri.UUCP> greg@utcsri.UUCP (Gregory Smith) writes: >In article <693@jenny.cl.cam.ac.uk> am@cl.cam.ac.uk (Alan Mycroft) writes: >> #define has_nullbyte_(x) ((x - 0x01010101) & ~x & 0x80808080) >>Then if e is an expression without side effects (e.g. variable) >> has_nullbyte_(e) >>is nonzero iff the value of e has a null byte. > >If one of the bytes contains 0x80, then has_nullbyte() will >say 'yes'. This can be circumvented by a more thorough test >after this one to see if there really is a null there. Untrue. It would be true if I had mistakenly used ^ instead of &~.