@@ -149,8 +149,7 @@ static void restore_line_number(void)
149149 if (skip_lines (rec_pos , line )) {
150150 if (ferror (word_file ))
151151 pexit ("fgets" );
152- fprintf_color (color_error , stderr , "fgets: Unexpected EOF\n" );
153- error ();
152+ error_msg ("fgets: Unexpected EOF\n" );
154153 }
155154}
156155
@@ -319,21 +318,16 @@ static MAYBE_INLINE void check_bom(char *line)
319318 return ;
320319
321320 if (!memcmp (line , "\xEF\xBB\xBF" , 3 )) {
322- static int warned ;
323-
324321 if (options .input_enc == UTF_8 )
325322 memmove (line , line + 3 , strlen (line ) - 2 );
326- else if (!warned ++ )
327- fprintf_color (color_warning , stderr , "Warning: UTF-8 BOM seen in wordlist. You probably want --input-encoding=UTF8\n" );
323+ else
324+ WARN_ONCE (color_warning , stderr ,
325+ "Warning: UTF-8 BOM seen in wordlist. You probably want --input-encoding=UTF8\n" );
328326 }
329327
330- if (options .input_enc == UTF_8 && (!memcmp (line , "\xFE\xFF" , 2 ) || !memcmp (line , "\xFF\xFE" , 2 ))) {
331- static int warned ;
332-
333- if (!warned ++ )
334- fprintf_color (color_warning , stderr ,
335- "Warning: UTF-16 BOM seen in wordlist. File may not be read properly unless you re-encode it\n" );
336- }
328+ if (options .input_enc == UTF_8 && (!memcmp (line , "\xFE\xFF" , 2 ) || !memcmp (line , "\xFF\xFE" , 2 )))
329+ WARN_ONCE (color_warning , stderr ,
330+ "Warning: UTF-16 BOM seen in wordlist. File may not be read properly unless you re-encode it\n" );
337331}
338332
339333/*
@@ -722,15 +716,12 @@ void do_wordlist_crack(struct db_main *db, const char *name, int rules)
722716 }
723717 if (i > my_size ) {
724718 fprintf_color (color_error , stderr ,
725- "Error: wordlist grew "
726- "as we read it - "
727- "aborting\n" );
719+ "Error: Wordlist grew as we read it - aborting\n" );
728720 error ();
729721 }
730722 }
731723 if (nWordFileLines != myWordFileLines )
732- fprintf_color (color_warning , stderr , "Warning: wordlist changed as"
733- " we read it\n" );
724+ WARN_ONCE (color_warning , stderr , "Warning: Wordlist changed as we read it\n" );
734725 log_event ("- Loaded this node's share of "
735726 "wordlist %s into memory "
736727 "(%" PRIu64 " bytes of %" PRId64 ", max_size=" Zu
@@ -769,12 +760,8 @@ void do_wordlist_crack(struct db_main *db, const char *name, int rules)
769760 "fread: Unexpected EOF\n" );
770761 error ();
771762 }
772- if (memchr (word_file_str , 0 , (size_t )file_len )) {
773- static int warned ;
774-
775- if (!warned ++ )
776- fprintf_color (color_warning , stderr , "Warning: Wordlist contains NUL bytes, lines may be truncated.\n" );
777- }
763+ if (memchr (word_file_str , 0 , (size_t )file_len ))
764+ WARN_ONCE (color_warning , stderr , "Warning: Wordlist contains NUL bytes, lines may be truncated.\n" );
778765 }
779766 aep = word_file_str + file_len ;
780767 * aep = 0 ;
@@ -827,13 +814,8 @@ void do_wordlist_crack(struct db_main *db, const char *name, int rules)
827814 {
828815 char * ep , ec ;
829816 if (i > nWordFileLines ) {
830- fprintf_color (color_warning , stderr , "Warning: wordlist "
831- "contains inconsequent "
832- "newlines, some words may be "
833- "skipped\n" );
834- log_event ("- Warning: wordlist contains"
835- " inconsequent newlines, some"
836- " words may be skipped" );
817+ WARN_LOG_ONCE (color_warning , stderr ,
818+ "Warning: Wordlist contains inconsequent newlines, some words may be skipped\n" );
837819 i -- ;
838820 break ;
839821 }
0 commit comments