home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume39 / phonewrd / patch02 < prev    next >
Encoding:
Text File  |  1993-09-07  |  4.2 KB  |  117 lines

  1. Newsgroups: comp.sources.misc
  2. From: erich@eye.com (Eric Haines)
  3. Subject: v39i073:  phonewrd - phone number phrase generator, Patch02
  4. Message-ID: <1993Sep7.132031.2687@sparky.sterling.com>
  5. X-Md4-Signature: fc809b5312104de877bca2ee2f96a128
  6. Sender: kent@sparky.sterling.com (Kent Landfield)
  7. Organization: Sterling Software
  8. Date: Tue, 7 Sep 1993 13:20:31 GMT
  9. Approved: kent@sparky.sterling.com
  10.  
  11. Submitted-by: erich@eye.com (Eric Haines)
  12. Posting-number: Volume 39, Issue 73
  13. Archive-name: phonewrd/patch02
  14. Environment: UNIX, DOS
  15. Patch-To: phonewrd: Volume 38, Issue 56
  16.  
  17. Here is patch #2 to phonewrd, the phone number phrase searching program.  It
  18. fixes an infinite loop condition if no match is found, along with a safer/
  19. less clunky tolower() function.
  20.  
  21. Eric Haines  erich@eye.com
  22.  
  23. *** old/patchlevel.h    Wed Sep  1 16:49:51 1993
  24. --- ./patchlevel.h    Wed Sep  1 17:05:45 1993
  25. ***************
  26. *** 1,2 ****
  27. ! #define VERSION        "version 2.1"
  28. ! #define PATCHLEVEL    1
  29. --- 1,2 ----
  30. ! #define VERSION        "version 2.2"
  31. ! #define PATCHLEVEL    2
  32. *** old/phonewrd.c    Fri Jul 30 10:15:12 1993
  33. --- ./phonewrd.c    Wed Sep  1 16:58:36 1993
  34. ***************
  35. *** 3,11 ****
  36.       which fit it.  See the man page for details, type "phonewrd -?" for
  37.       options.
  38.   
  39. !    version 2.1 - 7/16/93
  40.   
  41.      (c) copyright 1993, Eric Haines, all rights reserved (erich@eye.com)
  42.   
  43.   
  44.      History:
  45. --- 3,12 ----
  46.       which fit it.  See the man page for details, type "phonewrd -?" for
  47.       options.
  48.   
  49. !    version 2.2 - 9/1/93
  50.   
  51.      (c) copyright 1993, Eric Haines, all rights reserved (erich@eye.com)
  52. +        (distribute and use freely, just don't use inside commercial code)
  53.   
  54.   
  55.      History:
  56. ***************
  57. *** 14,19 ****
  58. --- 15,22 ----
  59.      2.1 - added sftolower for non-ANSI machines, added ctype.h include,
  60.        fixed error msg for GNU dictionary, added function prototypes,
  61.        made some casts explicit.
  62. +    2.2 - fixed infinite loop with "No matches ... trying again", less clunky
  63. +      & dangerous sftolower(), added copyright explanation.
  64.    */
  65.   
  66.   #include <stdlib.h>    /* if you don't have stdlib, use malloc.h instead,
  67. ***************
  68. *** 25,39 ****
  69.   /* safe tolower() macro - on some non-ANSI compliant machines, tolower()
  70.    * only works correctly for uppercase values, i.e. it simply subtracts an
  71.    * offset from the value passed in.  So, we need to test if the character is
  72. !  * uppercase before using tolower().  For the following macro, note that no
  73. !  * incrementing of the character should occur (e.g. sftolower(*str++) will
  74. !  * work incorrectly).  If your compiler has a tolower() function that works
  75. !  * correctly for all input (most compilers do) and you want the code to run
  76. !  * faster, just redefine sftolower as calling tolower, i.e.:
  77.    * #define    sftolower(c)    tolower((int)(c))
  78.    */
  79. ! #define    sftolower(c)                    \
  80. !     (((c) >= 'A' && (c) <= 'Z' ) ? tolower((int)(c)) : (c))
  81.   
  82.   
  83.   /* define USE_STRINGS_H if you use <strings.h> instead of <string.h> */
  84. --- 28,39 ----
  85.   /* safe tolower() macro - on some non-ANSI compliant machines, tolower()
  86.    * only works correctly for uppercase values, i.e. it simply subtracts an
  87.    * offset from the value passed in.  So, we need to test if the character is
  88. !  * uppercase before using tolower().  If your compiler has a tolower()
  89. !  * function that works correctly for all input (most compilers do) and you
  90. !  * want the code to run faster, just redefine sftolower as calling tolower:
  91.    * #define    sftolower(c)    tolower((int)(c))
  92.    */
  93. ! #define sftolower(c)    (isupper((int)(c)) ? tolower((int)(c)) : (c))
  94.   
  95.   
  96.   /* define USE_STRINGS_H if you use <strings.h> instead of <string.h> */
  97. ***************
  98. *** 420,427 ****
  99.           search_for_match( 0, out_string, out_string, 0 ) ;
  100.           if ( !MatchTot ) {
  101.           fprintf( stderr, "No matches with -n %d", NumNumerals ) ;
  102. !         if ( NumNumerals < NumDigits ) {
  103. !             NumNumerals++ ;
  104.               fprintf( stderr,
  105.                   ", trying again with -n %d\n", NumNumerals ) ;
  106.           } else {
  107. --- 420,426 ----
  108.           search_for_match( 0, out_string, out_string, 0 ) ;
  109.           if ( !MatchTot ) {
  110.           fprintf( stderr, "No matches with -n %d", NumNumerals ) ;
  111. !         if ( NumNumerals++ < NumDigits ) {
  112.               fprintf( stderr,
  113.                   ", trying again with -n %d\n", NumNumerals ) ;
  114.           } else {
  115.  
  116. exit 0 # Just in case...
  117.