301
310
message_print_comment_filepos (const message_ty *mp, ostream_t stream,
302
bool uniforum, size_t page_width)
311
bool uniforum, size_t page_width)
304
313
if (mp->filepos_count != 0)
306
315
begin_css_class (stream, class_reference_comment);
312
for (j = 0; j < mp->filepos_count; ++j)
314
lex_pos_ty *pp = &mp->filepos[j];
315
char *cp = pp->file_name;
318
while (cp[0] == '.' && cp[1] == '/')
320
ostream_write_str (stream, "# ");
321
begin_css_class (stream, class_reference);
322
/* There are two Sun formats to choose from: SunOS and
323
Solaris. Use the Solaris form here. */
324
str = xasprintf ("File: %s, line: %ld",
325
cp, (long) pp->line_number);
326
ostream_write_str (stream, str);
327
end_css_class (stream, class_reference);
328
ostream_write_str (stream, "\n");
321
for (j = 0; j < mp->filepos_count; ++j)
323
lex_pos_ty *pp = &mp->filepos[j];
324
const char *cp = pp->file_name;
327
while (cp[0] == '.' && cp[1] == '/')
329
ostream_write_str (stream, "# ");
330
begin_css_class (stream, class_reference);
331
/* There are two Sun formats to choose from: SunOS and
332
Solaris. Use the Solaris form here. */
333
str = xasprintf ("File: %s, line: %ld",
334
cp, (long) pp->line_number);
335
ostream_write_str (stream, str);
336
end_css_class (stream, class_reference);
337
ostream_write_str (stream, "\n");
337
ostream_write_str (stream, "#:");
339
for (j = 0; j < mp->filepos_count; ++j)
346
pp = &mp->filepos[j];
348
while (cp[0] == '.' && cp[1] == '/')
350
/* Some xgettext input formats, like RST, lack line numbers. */
351
if (pp->line_number == (size_t)(-1))
354
sprintf (buffer, ":%ld", (long) pp->line_number);
355
len = strlen (cp) + strlen (buffer) + 1;
356
if (column > 2 && column + len >= page_width)
358
ostream_write_str (stream, "\n#:");
361
ostream_write_str (stream, " ");
362
begin_css_class (stream, class_reference);
363
ostream_write_str (stream, cp);
364
ostream_write_str (stream, buffer);
365
end_css_class (stream, class_reference);
368
ostream_write_str (stream, "\n");
346
ostream_write_str (stream, "#:");
348
for (j = 0; j < mp->filepos_count; ++j)
355
pp = &mp->filepos[j];
357
while (cp[0] == '.' && cp[1] == '/')
359
/* Some xgettext input formats, like RST, lack line numbers. */
360
if (pp->line_number == (size_t)(-1))
363
sprintf (buffer, ":%ld", (long) pp->line_number);
364
len = strlen (cp) + strlen (buffer) + 1;
365
if (column > 2 && column + len >= page_width)
367
ostream_write_str (stream, "\n#:");
370
ostream_write_str (stream, " ");
371
begin_css_class (stream, class_reference);
372
ostream_write_str (stream, cp);
373
ostream_write_str (stream, buffer);
374
end_css_class (stream, class_reference);
377
ostream_write_str (stream, "\n");
371
380
end_css_class (stream, class_reference_comment);
376
/* Output mp->is_fuzzy, mp->is_format, mp->do_wrap as a comment line. */
385
/* Output mp->is_fuzzy, mp->is_format, mp->range, mp->do_wrap as a comment
379
389
message_print_comment_flags (const message_ty *mp, ostream_t stream, bool debug)
381
391
if ((mp->is_fuzzy && mp->msgstr[0] != '\0')
382
392
|| has_significant_format_p (mp->is_format)
393
|| has_range_p (mp->range)
383
394
|| mp->do_wrap == no)
385
396
bool first_flag = true;
390
401
ostream_write_str (stream, "#,");
392
403
/* We don't print the fuzzy flag if the msgstr is empty. This
393
might be introduced by the user but we want to normalize the
404
might be introduced by the user but we want to normalize the
395
406
if (mp->is_fuzzy && mp->msgstr[0] != '\0')
397
ostream_write_str (stream, " ");
398
begin_css_class (stream, class_flag);
399
begin_css_class (stream, class_fuzzy_flag);
400
ostream_write_str (stream, "fuzzy");
401
end_css_class (stream, class_fuzzy_flag);
402
end_css_class (stream, class_flag);
408
ostream_write_str (stream, " ");
409
begin_css_class (stream, class_flag);
410
begin_css_class (stream, class_fuzzy_flag);
411
ostream_write_str (stream, "fuzzy");
412
end_css_class (stream, class_fuzzy_flag);
413
end_css_class (stream, class_flag);
406
417
for (i = 0; i < NFORMATS; i++)
407
if (significant_format_p (mp->is_format[i]))
410
ostream_write_str (stream, ",");
412
ostream_write_str (stream, " ");
413
begin_css_class (stream, class_flag);
414
ostream_write_str (stream,
415
make_format_description_string (mp->is_format[i],
418
end_css_class (stream, class_flag);
418
if (significant_format_p (mp->is_format[i]))
421
ostream_write_str (stream, ",");
423
ostream_write_str (stream, " ");
424
begin_css_class (stream, class_flag);
425
ostream_write_str (stream,
426
make_format_description_string (mp->is_format[i],
429
end_css_class (stream, class_flag);
433
if (has_range_p (mp->range))
438
ostream_write_str (stream, ",");
440
ostream_write_str (stream, " ");
441
begin_css_class (stream, class_flag);
442
string = make_range_description_string (mp->range);
443
ostream_write_str (stream, string);
445
end_css_class (stream, class_flag);
422
449
if (mp->do_wrap == no)
425
ostream_write_str (stream, ",");
452
ostream_write_str (stream, ",");
427
ostream_write_str (stream, " ");
428
begin_css_class (stream, class_flag);
429
ostream_write_str (stream,
430
make_c_width_description_string (mp->do_wrap));
431
end_css_class (stream, class_flag);
454
ostream_write_str (stream, " ");
455
begin_css_class (stream, class_flag);
456
ostream_write_str (stream,
457
make_c_width_description_string (mp->do_wrap));
458
end_css_class (stream, class_flag);
435
462
ostream_write_str (stream, "\n");
659
691
for (es = s; *es != '\0'; )
663
695
/* Expand escape sequences in each portion. */
664
696
for (ep = s, portion_len = 0; ep < es; ep++)
669
else if (escape && !c_isprint ((unsigned char) c))
671
else if (c == '\\' || c == '"')
701
else if (escape && !c_isprint ((unsigned char) c))
703
else if (c == '\\' || c == '"')
676
if (conv != (iconv_t)(-1))
678
/* Skip over a complete multi-byte character. Don't
679
interpret the second byte of a multi-byte character as
680
ASCII. This is needed for the BIG5, BIG5-HKSCS, GBK,
681
GB18030, SHIFT_JIS, JOHAB encodings. */
683
const char *inptr = ep;
685
char *outptr = &scratchbuf[0];
686
size_t outsize = sizeof (scratchbuf);
708
if (conv != (iconv_t)(-1))
710
/* Skip over a complete multi-byte character. Don't
711
interpret the second byte of a multi-byte character as
712
ASCII. This is needed for the BIG5, BIG5-HKSCS, GBK,
713
GB18030, SHIFT_JIS, JOHAB encodings. */
715
const char *inptr = ep;
717
char *outptr = &scratchbuf[0];
718
size_t outsize = sizeof (scratchbuf);
690
for (insize = 1; inptr + insize <= es; insize++)
693
(ICONV_CONST char **) &inptr, &insize,
695
if (!(res == (size_t)(-1) && errno == EINVAL))
697
/* We expect that no input bytes have been consumed
702
if (res == (size_t)(-1))
706
po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
707
_("invalid multibyte sequence"));
714
portion_len += insize;
722
for (insize = 1; inptr + insize <= es; insize++)
725
(ICONV_CONST char **) &inptr, &insize,
727
if (!(res == (size_t)(-1) && errno == EINVAL))
729
/* We expect that no input bytes have been consumed
734
if (res == (size_t)(-1))
738
po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
739
_("invalid multibyte sequence"));
746
portion_len += insize;
721
/* Special handling of encodings with CJK structure. */
723
&& (unsigned char) ep[0] >= 0x80
724
&& (unsigned char) ep[1] >= 0x30)
753
/* Special handling of encodings with CJK structure. */
755
&& (unsigned char) ep[0] >= 0x80
756
&& (unsigned char) ep[1] >= 0x30)
734
766
portion = XNMALLOC (portion_len, char);
735
767
overrides = XNMALLOC (portion_len, char);
736
memset (overrides, UC_BREAK_UNDEFINED, portion_len);
737
768
attributes = XNMALLOC (portion_len, char);
738
769
for (ep = s, pp = portion, op = overrides, ap = attributes; ep < es; ep++)
741
char attr = (fmtdir != NULL ? fmtdir[ep - value] : 0);
746
case '\a': c = 'a'; break;
747
case '\b': c = 'b'; break;
748
case '\f': c = 'f'; break;
749
case '\n': c = 'n'; break;
750
case '\r': c = 'r'; break;
751
case '\t': c = 't'; break;
752
case '\v': c = 'v'; break;
758
*op++ = UC_BREAK_PROHIBITED;
759
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
760
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
761
/* We warn about any use of escape sequences beside
763
if (c != 'n' && c != 't')
765
char *error_message =
772
char attr = (fmtdirattr != NULL ? fmtdirattr[ep - value] : 0);
773
char brk = UC_BREAK_UNDEFINED;
774
/* Don't break inside format directives. */
775
if (attr == ATTR_FORMAT_DIRECTIVE
776
&& (fmtdir[ep - value] & FMTDIR_START) == 0)
777
brk = UC_BREAK_PROHIBITED;
782
case '\a': c = 'a'; break;
783
case '\b': c = 'b'; break;
784
case '\f': c = 'f'; break;
785
case '\n': c = 'n'; break;
786
case '\r': c = 'r'; break;
787
case '\t': c = 't'; break;
788
case '\v': c = 'v'; break;
794
*op++ = UC_BREAK_PROHIBITED;
795
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
796
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
797
/* We warn about any use of escape sequences beside
799
if (c != 'n' && c != 't')
801
char *error_message =
767
803
internationalized messages should not contain the `\\%c' escape sequence"),
769
po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0, false,
771
free (error_message);
774
else if (escape && !c_isprint ((unsigned char) c))
777
*pp++ = '0' + (((unsigned char) c >> 6) & 7);
778
*pp++ = '0' + (((unsigned char) c >> 3) & 7);
779
*pp++ = '0' + ((unsigned char) c & 7);
781
*op++ = UC_BREAK_PROHIBITED;
782
*op++ = UC_BREAK_PROHIBITED;
783
*op++ = UC_BREAK_PROHIBITED;
784
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
785
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
786
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
787
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
789
else if (c == '\\' || c == '"')
794
*op++ = UC_BREAK_PROHIBITED;
795
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
796
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
805
po_xerror (PO_SEVERITY_WARNING, mp, NULL, 0, 0, false,
807
free (error_message);
810
else if (escape && !c_isprint ((unsigned char) c))
813
*pp++ = '0' + (((unsigned char) c >> 6) & 7);
814
*pp++ = '0' + (((unsigned char) c >> 3) & 7);
815
*pp++ = '0' + ((unsigned char) c & 7);
817
*op++ = UC_BREAK_PROHIBITED;
818
*op++ = UC_BREAK_PROHIBITED;
819
*op++ = UC_BREAK_PROHIBITED;
820
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
821
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
822
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
823
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
825
else if (c == '\\' || c == '"')
830
*op++ = UC_BREAK_PROHIBITED;
831
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
832
*ap++ = attr | ATTR_ESCAPE_SEQUENCE;
801
if (conv != (iconv_t)(-1))
803
/* Copy a complete multi-byte character. Don't
804
interpret the second byte of a multi-byte character as
805
ASCII. This is needed for the BIG5, BIG5-HKSCS, GBK,
806
GB18030, SHIFT_JIS, JOHAB encodings. */
808
const char *inptr = ep;
810
char *outptr = &scratchbuf[0];
811
size_t outsize = sizeof (scratchbuf);
837
if (conv != (iconv_t)(-1))
839
/* Copy a complete multi-byte character. Don't
840
interpret the second byte of a multi-byte character as
841
ASCII. This is needed for the BIG5, BIG5-HKSCS, GBK,
842
GB18030, SHIFT_JIS, JOHAB encodings. */
844
const char *inptr = ep;
846
char *outptr = &scratchbuf[0];
847
size_t outsize = sizeof (scratchbuf);
815
for (insize = 1; inptr + insize <= es; insize++)
818
(ICONV_CONST char **) &inptr, &insize,
820
if (!(res == (size_t)(-1) && errno == EINVAL))
822
/* We expect that no input bytes have been consumed
827
if (res == (size_t)(-1))
831
po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0,
832
false, _("invalid multibyte sequence"));
839
memcpy_small (pp, ep, insize);
842
memset_small (ap, attr, insize);
851
for (insize = 1; inptr + insize <= es; insize++)
854
(ICONV_CONST char **) &inptr, &insize,
856
if (!(res == (size_t)(-1) && errno == EINVAL))
858
/* We expect that no input bytes have been consumed
863
if (res == (size_t)(-1))
867
po_xerror (PO_SEVERITY_ERROR, mp, NULL, 0, 0,
868
false, _("invalid multibyte sequence"));
875
memcpy_small (pp, ep, insize);
878
memset_small (op + 1, UC_BREAK_PROHIBITED, insize - 1);
880
memset_small (ap, attr, insize);
850
/* Special handling of encodings with CJK structure. */
852
&& (unsigned char) c >= 0x80
853
&& (unsigned char) ep[1] >= 0x30)
888
/* Special handling of encodings with CJK structure. */
890
&& (unsigned char) c >= 0x80
891
&& (unsigned char) ep[1] >= 0x30)
897
*op++ = UC_BREAK_PROHIBITED;
872
911
/* Don't break immediately before the "\n" at the end. */
873
912
if (es > s && es[-1] == '\n')
874
overrides[portion_len - 2] = UC_BREAK_PROHIBITED;
913
overrides[portion_len - 2] = UC_BREAK_PROHIBITED;
876
915
linebreaks = XNMALLOC (portion_len, char);
878
917
/* Subsequent lines after a break are all indented.
880
919
startcol_after_break = (line_prefix ? strlen (line_prefix) : 0);
882
startcol_after_break = (startcol_after_break + extra_indent + 8) & ~7;
921
startcol_after_break = (startcol_after_break + extra_indent + 8) & ~7;
883
922
startcol_after_break++;
885
924
/* The line width. Allow room for the closing quote character. */
891
930
/* The line starts with different things depending on whether it
892
is the first line, and if we are using the indented style.
931
is the first line, and if we are using the indented style.
894
933
startcol = (line_prefix ? strlen (line_prefix) : 0);
897
startcol += strlen (name);
899
startcol = (startcol + extra_indent + 8) & ~7;
936
startcol += strlen (name);
938
startcol = (startcol + extra_indent + 8) & ~7;
906
startcol = (startcol + extra_indent + 8) & ~7;
945
startcol = (startcol + extra_indent + 8) & ~7;
908
947
/* Allow room for the opening quote character. */
910
949
/* Adjust for indentation of subsequent lines. */
911
950
startcol -= startcol_after_break;
913
952
/* Do line breaking on the portion. */
914
mbs_width_linebreaks (portion, portion_len, width, startcol, 0,
915
overrides, canon_charset, linebreaks);
953
ulc_width_linebreaks (portion, portion_len, width, startcol, 0,
954
overrides, canon_charset, linebreaks);
917
956
/* If this is the first line, and we are not using the indented
918
style, and the line would wrap, then use an empty first line
957
style, and the line would wrap, then use an empty first line
920
959
if (first_line && !indent
924
|| memchr (linebreaks, UC_BREAK_POSSIBLE, portion_len) != NULL))
926
if (line_prefix != NULL)
927
ostream_write_str (stream, line_prefix);
928
begin_css_class (stream, css_class);
929
begin_css_class (stream, class_keyword);
930
ostream_write_str (stream, name);
931
end_css_class (stream, class_keyword);
932
ostream_write_str (stream, " ");
933
begin_css_class (stream, class_string);
934
ostream_write_str (stream, "\"\"");
935
end_css_class (stream, class_string);
936
end_css_class (stream, css_class);
937
ostream_write_str (stream, "\n");
939
/* Recompute startcol and linebreaks. */
963
|| memchr (linebreaks, UC_BREAK_POSSIBLE, portion_len) != NULL))
965
if (line_prefix != NULL)
966
ostream_write_str (stream, line_prefix);
967
begin_css_class (stream, css_class);
968
begin_css_class (stream, class_keyword);
969
ostream_write_str (stream, name);
970
end_css_class (stream, class_keyword);
971
ostream_write_str (stream, " ");
972
begin_css_class (stream, class_string);
973
ostream_write_str (stream, "\"\"");
974
end_css_class (stream, class_string);
975
end_css_class (stream, css_class);
976
ostream_write_str (stream, "\n");
978
/* Recompute startcol and linebreaks. */
943
982
/* Print the beginning of the line. This will depend on whether
944
this is the first line, and if the indented style is being
983
this is the first line, and if the indented style is being
949
if (line_prefix != NULL)
951
ostream_write_str (stream, line_prefix);
952
currcol = strlen (line_prefix);
954
begin_css_class (stream, css_class);
957
begin_css_class (stream, class_keyword);
958
ostream_write_str (stream, name);
959
currcol += strlen (name);
960
end_css_class (stream, class_keyword);
963
if (extra_indent > 0)
964
ostream_write_mem (stream, " ", extra_indent);
965
currcol += extra_indent;
966
ostream_write_mem (stream, " ", 8 - (currcol & 7));
967
currcol = (currcol + 8) & ~7;
971
ostream_write_str (stream, " ");
980
if (extra_indent > 0)
981
ostream_write_mem (stream, " ", extra_indent);
982
currcol += extra_indent;
983
ostream_write_mem (stream, " ", 8 - (currcol & 7));
984
currcol = (currcol + 8) & ~7;
988
if (line_prefix != NULL)
990
ostream_write_str (stream, line_prefix);
991
currcol = strlen (line_prefix);
993
begin_css_class (stream, css_class);
996
begin_css_class (stream, class_keyword);
997
ostream_write_str (stream, name);
998
currcol += strlen (name);
999
end_css_class (stream, class_keyword);
1002
if (extra_indent > 0)
1003
ostream_write_mem (stream, " ", extra_indent);
1004
currcol += extra_indent;
1005
ostream_write_mem (stream, " ", 8 - (currcol & 7));
1006
currcol = (currcol + 8) & ~7;
1010
ostream_write_str (stream, " ");
1019
if (extra_indent > 0)
1020
ostream_write_mem (stream, " ", extra_indent);
1021
currcol += extra_indent;
1022
ostream_write_mem (stream, " ", 8 - (currcol & 7));
1023
currcol = (currcol + 8) & ~7;
989
1028
/* Print the portion itself, with linebreaks where necessary. */
993
begin_css_class (stream, class_string);
994
ostream_write_str (stream, "\"");
995
begin_css_class (stream, class_text);
997
for (i = 0; i < portion_len; i++)
999
if (linebreaks[i] == UC_BREAK_POSSIBLE)
1003
/* Change currattr so that it becomes 0. */
1004
if (currattr & ATTR_ESCAPE_SEQUENCE)
1006
end_css_class (stream, class_escape_sequence);
1007
currattr &= ~ATTR_ESCAPE_SEQUENCE;
1009
if (currattr & ATTR_FORMAT_DIRECTIVE)
1011
end_css_class (stream, class_format_directive);
1012
currattr &= ~ATTR_FORMAT_DIRECTIVE;
1014
else if (currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1016
end_css_class (stream, class_invalid_format_directive);
1017
currattr &= ~ATTR_INVALID_FORMAT_DIRECTIVE;
1019
if (!(currattr == 0))
1022
end_css_class (stream, class_text);
1023
ostream_write_str (stream, "\"");
1024
end_css_class (stream, class_string);
1025
end_css_class (stream, css_class);
1026
ostream_write_str (stream, "\n");
1029
if (line_prefix != NULL)
1031
ostream_write_str (stream, line_prefix);
1032
currcol = strlen (line_prefix);
1034
begin_css_class (stream, css_class);
1037
ostream_write_mem (stream, " ", 8 - (currcol & 7));
1038
currcol = (currcol + 8) & ~7;
1040
begin_css_class (stream, class_string);
1041
ostream_write_str (stream, "\"");
1042
begin_css_class (stream, class_text);
1044
/* Change currattr so that it matches attributes[i]. */
1045
if (attributes[i] != currattr)
1047
/* class_escape_sequence occurs inside class_format_directive
1048
and class_invalid_format_directive, so clear it first. */
1049
if (currattr & ATTR_ESCAPE_SEQUENCE)
1051
end_css_class (stream, class_escape_sequence);
1052
currattr &= ~ATTR_ESCAPE_SEQUENCE;
1054
if (~attributes[i] & currattr & ATTR_FORMAT_DIRECTIVE)
1056
end_css_class (stream, class_format_directive);
1057
currattr &= ~ATTR_FORMAT_DIRECTIVE;
1059
else if (~attributes[i] & currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1061
end_css_class (stream, class_invalid_format_directive);
1062
currattr &= ~ATTR_INVALID_FORMAT_DIRECTIVE;
1064
if (attributes[i] & ~currattr & ATTR_FORMAT_DIRECTIVE)
1066
begin_css_class (stream, class_format_directive);
1067
currattr |= ATTR_FORMAT_DIRECTIVE;
1069
else if (attributes[i] & ~currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1071
begin_css_class (stream, class_invalid_format_directive);
1072
currattr |= ATTR_INVALID_FORMAT_DIRECTIVE;
1074
/* class_escape_sequence occurs inside class_format_directive
1075
and class_invalid_format_directive, so set it last. */
1076
if (attributes[i] & ~currattr & ATTR_ESCAPE_SEQUENCE)
1078
begin_css_class (stream, class_escape_sequence);
1079
currattr |= ATTR_ESCAPE_SEQUENCE;
1082
ostream_write_mem (stream, &portion[i], 1);
1085
/* Change currattr so that it becomes 0. */
1086
if (currattr & ATTR_ESCAPE_SEQUENCE)
1088
end_css_class (stream, class_escape_sequence);
1089
currattr &= ~ATTR_ESCAPE_SEQUENCE;
1091
if (currattr & ATTR_FORMAT_DIRECTIVE)
1093
end_css_class (stream, class_format_directive);
1094
currattr &= ~ATTR_FORMAT_DIRECTIVE;
1096
else if (currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1098
end_css_class (stream, class_invalid_format_directive);
1099
currattr &= ~ATTR_INVALID_FORMAT_DIRECTIVE;
1101
if (!(currattr == 0))
1104
end_css_class (stream, class_text);
1105
ostream_write_str (stream, "\"");
1106
end_css_class (stream, class_string);
1107
end_css_class (stream, css_class);
1108
ostream_write_str (stream, "\n");
1032
begin_css_class (stream, class_string);
1033
ostream_write_str (stream, "\"");
1034
begin_css_class (stream, class_text);
1036
for (i = 0; i < portion_len; i++)
1038
if (linebreaks[i] == UC_BREAK_POSSIBLE)
1042
/* Change currattr so that it becomes 0. */
1043
if (currattr & ATTR_ESCAPE_SEQUENCE)
1045
end_css_class (stream, class_escape_sequence);
1046
currattr &= ~ATTR_ESCAPE_SEQUENCE;
1048
if (currattr & ATTR_FORMAT_DIRECTIVE)
1050
end_css_class (stream, class_format_directive);
1051
currattr &= ~ATTR_FORMAT_DIRECTIVE;
1053
else if (currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1055
end_css_class (stream, class_invalid_format_directive);
1056
currattr &= ~ATTR_INVALID_FORMAT_DIRECTIVE;
1058
if (!(currattr == 0))
1061
end_css_class (stream, class_text);
1062
ostream_write_str (stream, "\"");
1063
end_css_class (stream, class_string);
1064
end_css_class (stream, css_class);
1065
ostream_write_str (stream, "\n");
1068
if (line_prefix != NULL)
1070
ostream_write_str (stream, line_prefix);
1071
currcol = strlen (line_prefix);
1073
begin_css_class (stream, css_class);
1076
ostream_write_mem (stream, " ", 8 - (currcol & 7));
1077
currcol = (currcol + 8) & ~7;
1079
begin_css_class (stream, class_string);
1080
ostream_write_str (stream, "\"");
1081
begin_css_class (stream, class_text);
1083
/* Change currattr so that it matches attributes[i]. */
1084
if (attributes[i] != currattr)
1086
/* class_escape_sequence occurs inside class_format_directive
1087
and class_invalid_format_directive, so clear it first. */
1088
if (currattr & ATTR_ESCAPE_SEQUENCE)
1090
end_css_class (stream, class_escape_sequence);
1091
currattr &= ~ATTR_ESCAPE_SEQUENCE;
1093
if (~attributes[i] & currattr & ATTR_FORMAT_DIRECTIVE)
1095
end_css_class (stream, class_format_directive);
1096
currattr &= ~ATTR_FORMAT_DIRECTIVE;
1098
else if (~attributes[i] & currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1100
end_css_class (stream, class_invalid_format_directive);
1101
currattr &= ~ATTR_INVALID_FORMAT_DIRECTIVE;
1103
if (attributes[i] & ~currattr & ATTR_FORMAT_DIRECTIVE)
1105
begin_css_class (stream, class_format_directive);
1106
currattr |= ATTR_FORMAT_DIRECTIVE;
1108
else if (attributes[i] & ~currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1110
begin_css_class (stream, class_invalid_format_directive);
1111
currattr |= ATTR_INVALID_FORMAT_DIRECTIVE;
1113
/* class_escape_sequence occurs inside class_format_directive
1114
and class_invalid_format_directive, so set it last. */
1115
if (attributes[i] & ~currattr & ATTR_ESCAPE_SEQUENCE)
1117
begin_css_class (stream, class_escape_sequence);
1118
currattr |= ATTR_ESCAPE_SEQUENCE;
1121
ostream_write_mem (stream, &portion[i], 1);
1124
/* Change currattr so that it becomes 0. */
1125
if (currattr & ATTR_ESCAPE_SEQUENCE)
1127
end_css_class (stream, class_escape_sequence);
1128
currattr &= ~ATTR_ESCAPE_SEQUENCE;
1130
if (currattr & ATTR_FORMAT_DIRECTIVE)
1132
end_css_class (stream, class_format_directive);
1133
currattr &= ~ATTR_FORMAT_DIRECTIVE;
1135
else if (currattr & ATTR_INVALID_FORMAT_DIRECTIVE)
1137
end_css_class (stream, class_invalid_format_directive);
1138
currattr &= ~ATTR_INVALID_FORMAT_DIRECTIVE;
1140
if (!(currattr == 0))
1143
end_css_class (stream, class_text);
1144
ostream_write_str (stream, "\"");
1145
end_css_class (stream, class_string);
1146
end_css_class (stream, css_class);
1147
ostream_write_str (stream, "\n");
1111
1150
free (linebreaks);
1407
1448
char *allocated_charset;
1409
1450
/* If the first domain is the default, don't bother emitting
1410
the domain name, because it is the default. */
1451
the domain name, because it is the default. */
1412
&& strcmp (mdlp->item[k]->domain, MESSAGE_DOMAIN_DEFAULT) == 0))
1415
print_blank_line (stream);
1416
begin_css_class (stream, class_keyword);
1417
ostream_write_str (stream, "domain");
1418
end_css_class (stream, class_keyword);
1419
ostream_write_str (stream, " ");
1420
begin_css_class (stream, class_string);
1421
ostream_write_str (stream, "\"");
1422
begin_css_class (stream, class_text);
1423
ostream_write_str (stream, mdlp->item[k]->domain);
1424
end_css_class (stream, class_text);
1425
ostream_write_str (stream, "\"");
1426
end_css_class (stream, class_string);
1427
ostream_write_str (stream, "\n");
1453
&& strcmp (mdlp->item[k]->domain, MESSAGE_DOMAIN_DEFAULT) == 0))
1456
print_blank_line (stream);
1457
begin_css_class (stream, class_keyword);
1458
ostream_write_str (stream, "domain");
1459
end_css_class (stream, class_keyword);
1460
ostream_write_str (stream, " ");
1461
begin_css_class (stream, class_string);
1462
ostream_write_str (stream, "\"");
1463
begin_css_class (stream, class_text);
1464
ostream_write_str (stream, mdlp->item[k]->domain);
1465
end_css_class (stream, class_text);
1466
ostream_write_str (stream, "\"");
1467
end_css_class (stream, class_string);
1468
ostream_write_str (stream, "\n");
1431
1472
mlp = mdlp->item[k]->messages;
1433
1474
/* Search the header entry. */
1435
1476
for (j = 0; j < mlp->nitems; ++j)
1436
if (is_header (mlp->item[j]) && !mlp->item[j]->obsolete)
1438
header = mlp->item[j]->msgstr;
1477
if (is_header (mlp->item[j]) && !mlp->item[j]->obsolete)
1479
header = mlp->item[j]->msgstr;
1442
1483
/* Extract the charset name. */
1443
1484
charset = "ASCII";
1444
1485
allocated_charset = NULL;
1445
1486
if (header != NULL)
1447
const char *charsetstr = c_strstr (header, "charset=");
1449
if (charsetstr != NULL)
1453
charsetstr += strlen ("charset=");
1454
len = strcspn (charsetstr, " \t\n");
1455
allocated_charset = (char *) xmalloca (len + 1);
1456
memcpy (allocated_charset, charsetstr, len);
1457
allocated_charset[len] = '\0';
1458
charset = allocated_charset;
1460
/* Treat the dummy default value as if it were absent. */
1461
if (strcmp (charset, "CHARSET") == 0)
1488
const char *charsetstr = c_strstr (header, "charset=");
1490
if (charsetstr != NULL)
1494
charsetstr += strlen ("charset=");
1495
len = strcspn (charsetstr, " \t\n");
1496
allocated_charset = (char *) xmalloca (len + 1);
1497
memcpy (allocated_charset, charsetstr, len);
1498
allocated_charset[len] = '\0';
1499
charset = allocated_charset;
1501
/* Treat the dummy default value as if it were absent. */
1502
if (strcmp (charset, "CHARSET") == 0)
1466
1507
/* Write out each of the messages for this domain. */
1467
1508
for (j = 0; j < mlp->nitems; ++j)
1468
if (!mlp->item[j]->obsolete)
1470
message_print (mlp->item[j], stream, charset, page_width,
1509
if (!mlp->item[j]->obsolete)
1511
message_print (mlp->item[j], stream, charset, page_width,
1475
1516
/* Write out each of the obsolete messages for this domain. */
1476
1517
for (j = 0; j < mlp->nitems; ++j)
1477
if (mlp->item[j]->obsolete)
1479
message_print_obsolete (mlp->item[j], stream, charset, page_width,
1518
if (mlp->item[j]->obsolete)
1520
message_print_obsolete (mlp->item[j], stream, charset, page_width,
1484
1525
if (allocated_charset != NULL)
1485
freea (allocated_charset);
1526
freea (allocated_charset);