home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / alt / hackers / 2011 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.1 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!doc.ic.ac.uk!warwick!uknet!comlab.ox.ac.uk!pcl
  2. From: pcl@ox.ac.uk (Paul C Leyland)
  3. Newsgroups: alt.hackers
  4. Subject: Re: Stupid macro tricks...
  5. Message-ID: <PCL.93Jan28095624@rhodium.ox.ac.uk>
  6. Date: 28 Jan 93 09:56:24 GMT
  7. References: <C1DnqE.L3u@mentor.cc.purdue.edu>
  8. Organization: Oxford University Computing Services, 13 Banbury Rd Oxford OX2
  9.     6NN
  10. Lines: 41
  11. Approved: Of course it is approved.
  12. In-reply-to: daffnelr@mentor.cc.purdue.edu's message of 24 Jan 93 21:30:13 GMT
  13.  
  14. In article <C1DnqE.L3u@mentor.cc.purdue.edu> daffnelr@mentor.cc.purdue.edu (Throatwarbler Mangrove) writes:
  15.  
  16.      Hey.. anyone out there got really
  17.    ugly/complicated/elegant/interesting macros in any of their programs?
  18.    As for the ugly part, it seems that bit manipulations can get that
  19.    way very easily... Maybe we should have a contest for the ugliest
  20.    macro that works for its intended purpose (that you've actually used
  21.    in a program other than a test prog to see if it works..) Anyone got a
  22.  
  23.  
  24. Here's what I wrote when modifying dvi2ps to read .pk format fonts.  I
  25. needed to speed up the nybble and bit-addressing functions.  Since
  26. then, I've seen them crop up in other dvi-handling code, usually
  27. without attribution.  8-(
  28.  
  29. 8<----------------->8
  30.  
  31. /* Converted from functions to macros for speed.  Pcl 6/8/87 */
  32. /* return rounded number of pixels */
  33. #define PixRound(x, conv) (int)(((x) + ((conv) >> 1)) / (conv))
  34. #define pk_byte(x) (*char_p++)
  35. #define get_nyb(x) (((nyb_ptr ^= TRUE) ? *char_p >> 4 : *char_p++) & 15)
  36. #define get_bit(x) (((bit_ptr >>= 1) ? \
  37.              (*char_p & bit_ptr) : \
  38.              (*++char_p & (bit_ptr = 128))) > 0)
  39.  
  40. 8<----------------->8
  41.  
  42.  
  43. I particularly liked the get_bit macro.
  44.  
  45. God.  5.5 years ago!  I'm getting old ...
  46.  
  47.  
  48. Paul
  49. --
  50. Paul Leyland <pcl@oxford.ac.uk>          | Hanging on in quiet desperation is
  51. Oxford University Computing Service      |     the English way.
  52. 13 Banbury Road, Oxford, OX2 6NN, UK     | The time is come, the song is over.
  53. Tel: +44-865-273200  Fax: +44-865-273275 | Thought I'd something more to say.
  54. Finger pcl@black.ox.ac.uk for PGP key    |
  55.