home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1401 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  871 b 

  1. From: rsalz@bbn.com (Rich Salz)
  2. Newsgroups: comp.lang.c,alt.sources
  3. Subject: Re: How can I de-escape my strings at run time?
  4. Message-ID: <2598@litchi.bbn.com>
  5. Date: 1 Jun 90 16:15:32 GMT
  6.  
  7. Oops...
  8.  
  9. From: Kevin Braunsdorf <ksb@nostromo.cc.purdue.edu>
  10. To: rsalz@BBN.COM
  11.  
  12. In article <2596@litchi.bbn.com> you write:
  13. |        case 'x':
  14. |        for (*p = 0; *++text && isxdigit(*text); )
  15. |            if (isdigit(*text))
  16. |            *p = (*p << 4) + *text - '0';
  17. |            else if (isupper(*text))
  18. |            *p = (*p << 4) + *text - 'A';
  19. |            else
  20. |            *p = (*p << 4) + *text - 'a';
  21. |        text--;
  22. |        break;
  23. Nope.  You forgot to add 10 for the 'a' and 'A' case.
  24.             *p = (*p << 4) + *text - 'A' + 10;
  25.             else
  26.             *p = (*p << 4) + *text - 'a' + 10;
  27.  
  28. Sorry about that.
  29. -- 
  30. Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
  31. Use a domain-based address or give alternate paths, or you may lose out.
  32.