POSIX.1 National Language Support API for MinGW
修订版 | 182556be764e61e7d7eaa56ae9600300e82e8a65 (tree) |
---|---|
时间 | 2007-05-18 03:45:08 |
作者 | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Correct mcsource.c r1.7 logic defect; tidy up DEBUG mode output formatting.
@@ -1,3 +1,9 @@ | ||
1 | +2007-05-17 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + * mcsource.c (mc_source): Adjust block nesting to correct logic | |
4 | + defect introduced in revision 1.7 (2007-05-14). | |
5 | + [DEBUG]: Tidy up formatting of some ugly debugging messages. | |
6 | + | |
1 | 7 | 2007-05-14 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 8 | |
3 | 9 | * mcsource.c (mc_source): Close `input_fd' prior to every use |
@@ -206,6 +206,8 @@ struct msgdict *mc_source( const char *input ) | ||
206 | 206 | { |
207 | 207 | # define CODESET_DECLARED codeset_decl_src, codeset_decl_lineno |
208 | 208 | |
209 | + dinvoke( int dtrace = 0; ) | |
210 | + | |
209 | 211 | long accumulator; |
210 | 212 | int fd, input_fd, count; |
211 | 213 | char buf[BUFSIZ], keyword[64]; |
@@ -357,6 +359,7 @@ struct msgdict *mc_source( const char *input ) | ||
357 | 359 | else |
358 | 360 | { |
359 | 361 | xcount += skip; |
362 | + dinvoke(( dtrace = dtrace ? dtrace : fprintf( stderr, "\n%s:%u:scan input: ", input, linenum ) )); | |
360 | 363 | dfputc(( c, stderr )); |
361 | 364 | } |
362 | 365 | } |
@@ -687,7 +690,7 @@ struct msgdict *mc_source( const char *input ) | ||
687 | 690 | */ |
688 | 691 | size_t len = 0; |
689 | 692 | status &= ~ESCAPE; |
690 | - dfprintf(( stderr, "%s:%u:", input, linenum )); | |
693 | + dfprintf(( stderr, "\n%s:%u:", input, linenum )); | |
691 | 694 | switch( c ) |
692 | 695 | { |
693 | 696 | /* Thus, for the standard escape sequences ... |
@@ -781,6 +784,7 @@ struct msgdict *mc_source( const char *input ) | ||
781 | 784 | else |
782 | 785 | { |
783 | 786 | xcount += skip; |
787 | + dinvoke(( dtrace = dtrace ? dtrace : fprintf( stderr, "\n%s:%u:scan input: ", input, linenum ) )); | |
784 | 788 | dfputc(( c, stderr )); |
785 | 789 | } |
786 | 790 | } |
@@ -790,40 +794,40 @@ struct msgdict *mc_source( const char *input ) | ||
790 | 794 | status |= FLUSH; |
791 | 795 | } |
792 | 796 | } |
797 | + } | |
793 | 798 | |
794 | - if( c == L'\n' ) | |
795 | - { | |
796 | - /* Mark the end of the current input line, | |
797 | - * and schedule any pending message data from this line | |
798 | - * for flushing to the message collection buffer. | |
799 | - */ | |
800 | - status |= NEWLINE | FLUSH; | |
799 | + if( c == L'\n' ) | |
800 | + { | |
801 | + /* Mark the end of the current input line, | |
802 | + * and schedule flushing of any pending message data from this line | |
803 | + * to the message collection buffer. | |
804 | + */ | |
805 | + status |= NEWLINE | FLUSH; | |
801 | 806 | |
802 | - /* If "QUOTED" context remains active, at the end of this line, | |
803 | - * then we have an implicit continuation, so force it. | |
804 | - */ | |
805 | - if( (status & QUOTED) == QUOTED ) | |
806 | - status |= CONTINUED; | |
807 | + /* If "QUOTED" context remains active, at the end of this line, | |
808 | + * then we have an implicit continuation, so force it. | |
809 | + */ | |
810 | + if( (status & QUOTED) == QUOTED ) | |
811 | + status |= CONTINUED; | |
807 | 812 | |
808 | - /* Clean up the context of any pending directive processing. | |
809 | - */ | |
810 | - switch( status & CATEGORY ) | |
811 | - { | |
812 | - case DEFQUOTE: | |
813 | - /* | |
814 | - * If we see end of line with a DEFQUOTE pending, then | |
815 | - * there was no defining character with the "quote" directive, | |
816 | - * so we must disable "quote" character recognition. | |
817 | - */ | |
818 | - quote = L'\0'; | |
819 | - dfprintf(( stderr, ": none assigned" )); | |
820 | - break; | |
821 | - } | |
813 | + /* Clean up the context of any pending directive processing. | |
814 | + */ | |
815 | + switch( status & CATEGORY ) | |
816 | + { | |
817 | + case DEFQUOTE: | |
818 | + /* | |
819 | + * If we see end of line with a DEFQUOTE pending, then | |
820 | + * there was no defining character with the "quote" directive, | |
821 | + * so we must disable "quote" character recognition. | |
822 | + */ | |
823 | + quote = L'\0'; | |
824 | + dfprintf(( stderr, ": none assigned" )); | |
825 | + break; | |
826 | + } | |
822 | 827 | |
823 | - if( (status & CONTINUED) == 0 ) | |
824 | - { | |
825 | - status &= ~ENCODED; | |
826 | - } | |
828 | + if( (status & CONTINUED) == 0 ) | |
829 | + { | |
830 | + status &= ~ENCODED; | |
827 | 831 | } |
828 | 832 | } |
829 | 833 | } |
@@ -834,10 +838,11 @@ struct msgdict *mc_source( const char *input ) | ||
834 | 838 | * which now needs to be flushed to the output queue, |
835 | 839 | * BEFORE we proceed to the next cycle. |
836 | 840 | */ |
841 | + dinvoke(( dtrace = 0 )); | |
837 | 842 | while( headroom < (xcount + ICONV_MB_LEN_MAX) ) |
838 | 843 | { |
839 | 844 | headroom += BUFSIZ; |
840 | - dfprintf(( stderr, "<grow allocation to %u bytes>", (unsigned)(msgloc + headroom) )); | |
845 | + dfprintf(( stderr, "\n%s:%u:insufficient workspace remaining; grow allocation to %u bytes", input, linenum, (unsigned)(msgloc + headroom) )); | |
841 | 846 | if( (messages = realloc( messages, msgloc + headroom )) == NULL ) |
842 | 847 | { |
843 | 848 | gencat_errno = mc_errout( FATAL( MSG_OUT_OF_MEMORY )); |
@@ -849,7 +854,7 @@ struct msgdict *mc_source( const char *input ) | ||
849 | 854 | dfprintf(( stderr, "\n%s:%u:", input, linenum )); |
850 | 855 | msgloc = mc_update_workspace( messages + msgloc, p - xcount - skip, xcount ) |
851 | 856 | - messages; |
852 | - dfprintf(( stderr, "; %u byte%s free\n", headroom, headroom == 1 ? "" : "s" )); | |
857 | + dfprintf(( stderr, "; %u byte%s free", headroom, headroom == 1 ? "" : "s" )); | |
853 | 858 | if( (status & (MSGTEXT | NEWLINE | CONTINUED)) == (MSGTEXT | NEWLINE) ) |
854 | 859 | { |
855 | 860 | wchar_t terminator = L'\0'; |
@@ -976,4 +981,4 @@ struct msgdict *mc_source( const char *input ) | ||
976 | 981 | return head; |
977 | 982 | } |
978 | 983 | |
979 | -/* $RCSfile$Revision: 1.6 $: end of file */ | |
984 | +/* $RCSfile$Revision: 1.8 $: end of file */ |