🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.dcom.telecom
Article #293

phonewrd 1.5, patch #1

#293
From: Eric Haines
Date: Wed, 02 Jun 1993 13:25
136 lines
4553 bytes
Here's the first patch to the phonewrd.c (version 1.5) program (turns phone
numbers into phrases) posted recently.  It makes the program automatically
widen the search if no match is found initially (thanks to Charles Howe for
bugging me about this).

Eric

*** phonewrd.15.c	Tue Apr 27 14:47:20 1993
--- phonewrd.c	Wed Jun  2 09:22:28 1993
***************
*** 2,8 ****
     Phonewrd - given a phone number, find all words or phrases in a dictionary
       which fit it.
  
!    version 1.5 - 4/21/93
  
     (c) copyright 1993, Eric Haines, all rights reserved (erich@eye.com)
  
--- 2,8 ----
     Phonewrd - given a phone number, find all words or phrases in a dictionary
       which fit it.
  
!    version 1.6 - 6/1/93
  
     (c) copyright 1993, Eric Haines, all rights reserved (erich@eye.com)
  
***************
*** 10,15 ****
--- 10,18 ----
  
     History:
  
+    1.6 changes:  added "count-up" for number of numerals which stay numerals
+ 	(i.e. -n value).  We count up until any match is found.  Also fixed
+ 	dictionary path bug.
     1.5 changes:  added the ability to recognize and expand GNU ispell
  	dictionary words.  Multiple dictionaries can also be input.
     1.4 changes:  another change in search_for_match to avoid out of bounds
***************
*** 303,310 ****
      }
  
      if ( NumDigits > MAX_DIGITS ) {
! 	fprintf(stderr, "Sorry, too many digits input in `%s'; ", numeral_string);
! 	fprintf(stderr, "only %d allowed.\n", NumDigits);
  	USAGE ;
  	return(0) ;
      }
--- 306,314 ----
      }
  
      if ( NumDigits > MAX_DIGITS ) {
! 	fprintf(stderr, "Sorry, too many digits input in `%s'; ",
! 		numeral_string);
! 	fprintf(stderr, "only %d allowed.\n", MAX_DIGITS);
  	USAGE ;
  	return(0) ;
      }
***************
*** 357,369 ****
      if ( word_count ) {
  	/* good, there's something to work with: search away! */
  	*out_string = '\0' ;
! 	search_for_match( 0, out_string, out_string, 0 ) ;
  	if ( !MatchTot ) {
  	    fprintf( stderr,
! 		"Bad luck: dictionary words fit, but there's too much numeral goop.\n");
  	    fprintf( stderr,
! 		"I'd try again with the option `-n %d' or so.\n",
! 		NumNumerals+1 ) ;
  	}
      } else {
  	fprintf( stderr,
--- 361,385 ----
      if ( word_count ) {
  	/* good, there's something to work with: search away! */
  	*out_string = '\0' ;
! 	while ( !MatchTot && ( NumNumerals <= NumDigits ) ) {
! 	    search_for_match( 0, out_string, out_string, 0 ) ;
! 	    if ( !MatchTot ) {
! 		fprintf( stderr, "No matches with -n %d", NumNumerals ) ;
! 		if ( NumNumerals < NumDigits ) {
! 		    NumNumerals++ ;
! 		    fprintf( stderr,
! 			    ", trying again with -n %d\n", NumNumerals ) ;
! 		} else {
! 		    fprintf( stderr, "\n" ) ;
! 		}
! 	    }
! 	}
  	if ( !MatchTot ) {
  	    fprintf( stderr,
! 	"Bad luck: dictionary words fit, but there's too much numeral goop.\n");
  	    fprintf( stderr,
! "Maybe try again with the option `-s abcdgimoptuxy248' or try wildcarding.\n"
! 		    ) ;
  	}
      } else {
  	fprintf( stderr,
***************
*** 370,376 ****
  		"Worst luck: no dictionary words fit anywhere in %s.\n",
  		PhoneStr ) ;
  	fprintf( stderr,
! 		"Maybe try again with the option `-s abcdgimoptuxy248'.\n" ) ;
      }
  
      free_wl() ;
--- 386,393 ----
  		"Worst luck: no dictionary words fit anywhere in %s.\n",
  		PhoneStr ) ;
  	fprintf( stderr,
! "Maybe try again with the option `-s abcdgimoptuxy248' or try wildcarding.\n"
! 		    ) ;
      }
  
      free_wl() ;
***************
*** 1228,1235 ****
  			    free( *DictPath ) ;
  			}
  			sscanf( argv[num_arg], "%s", str ) ;
! 			if ( *str == '.' ) {
! 			    /* use the default dictionary */
  			    strcpy( str, DICT_PATH ) ;
  			}
  			DictPath[DictTot] = str_duplicate( str ) ;
--- 1245,1252 ----
  			    free( *DictPath ) ;
  			}
  			sscanf( argv[num_arg], "%s", str ) ;
! 			if ( (str[0] == '.') && ( str[1] == NULL ) ) {
! 			    /* for '.' use the default dictionary */
  			    strcpy( str, DICT_PATH ) ;
  			}
  			DictPath[DictTot] = str_duplicate( str ) ;
Technical Details
Message-ID: <1993Jun2.092543.14664@eye.com>
Path: arc1-ca.pugleaf.net!wupost!udel!news.intercon.com!psinntp!eye!erich

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!udel!news.intercon.com!psinntp!eye!erich
From: erich@eye.com (Eric Haines)
Newsgroups: alt.dcom.telecom,alt.sources
Subject: phonewrd 1.5, patch #1
Message-ID: <1993Jun2.092543.14664@eye.com>
Date: Wed, 2 Jun 93 13:25:42 GMT
Summary: automatically widen the search
Sender: erich@eye.com (Eric Haines)
Organization: 3D/EYE, Inc.  Ithaca, NY
Lines: 136