1 diff -ur coreutils-7.6.org/po/pl.po coreutils-7.6/po/pl.po
2 --- coreutils-7.6.org/po/pl.po 2009-09-12 20:25:34.788233704 +0200
3 +++ coreutils-7.6/po/pl.po 2009-09-12 20:25:11.898026716 +0200
4 @@ -4202,12 +4202,14 @@
7 " -t, --tagged-paragraph indentation of first line different from second\n"
8 -" -u, --uniform-spacing one space between words, two after sentences\n"
9 +" -u, --uniform-spacing one space between words, two between sentences\n"
10 +" -n, --single-spaces single spaces between sentences\n"
11 " -w, --width=WIDTH maximum line width (default of 75 columns)\n"
13 " -t, --tagged-paragraph wcięcie pierwszej linii inne niż drugiej\n"
14 " -u, --uniform-spacing jedna spacja między słowami, dwie między "
16 +" -n, --single-spaces pojedyncze spacje między zdaniami\n"
17 " -w, --width=ILE maksymalna szerokość linii (domyślnie 75 "
20 diff -ur coreutils-7.6.org/src/fmt.c coreutils-7.6/src/fmt.c
21 --- coreutils-7.6.org/src/fmt.c 2009-09-01 13:01:16.000000000 +0200
22 +++ coreutils-7.6/src/fmt.c 2009-09-12 20:25:11.894693234 +0200
24 /* Written by Ross Paterson <rap@doc.ic.ac.uk>. */
29 #include <sys/types.h>
32 /* The following parameters represent the program's idea of what is
33 "best". Adjust to taste, subject to the caveats given. */
35 -/* Default longest permitted line length (max_width). */
36 +/* Default longest permitted line width (max_width). */
39 /* Prefer lines to be LEEWAY % shorter than the maximum width, giving
43 /* Costs and bonuses are expressed as the equivalent departure from the
44 - optimal line length, multiplied by 10. e.g. assigning something a
45 + optimal line width, multiplied by 10. e.g. assigning something a
46 cost of 50 means that it is as bad as a line 5 characters too short
47 or too long. The definition of SHORT_COST(n) should not be changed.
48 However, EQUIV(n) may need tuning. */
50 #define LINE_COST EQUIV (70)
52 /* Cost of breaking a line after the first word of a sentence, where
53 - the length of the word is N. */
54 + the width of the word is N. */
55 #define WIDOW_COST(n) (EQUIV (200) / ((n) + 2))
57 /* Cost of breaking a line before the last word of a sentence, where
58 - the length of the word is N. */
59 + the width of the word is N. */
60 #define ORPHAN_COST(n) (EQUIV (150) / ((n) + 2))
62 /* Bonus for breaking a line at the end of a sentence. */
67 +/* Wide character support */
70 +xgetwc (FILE *stream)
72 + wint_t c = getwc (stream);
73 + if (c == WEOF && ferror (stream))
74 + error (EXIT_FAILURE, errno, _("read error"));
79 +xwcwidth (wchar_t wc)
81 + int w = wcwidth (wc);
82 + return w < 0 ? 0 : w;
85 /* Extra ctype(3)-style macros. */
87 -#define isopen(c) (strchr ("([`'\"", c) != NULL)
88 -#define isclose(c) (strchr (")]'\"", c) != NULL)
89 -#define isperiod(c) (strchr (".?!", c) != NULL)
91 + (wcschr (L"([`'\"\u2018\u201A\u201B\u201C\u201E\u201F", c) != NULL)
92 +#define isclose(c) (wcschr (L")]'\"\u2018\u2019\u201C\u201D", c) != NULL)
93 +#define isperiod(c) (wcschr (L".?!", c) != NULL)
95 /* Size of a tab stop, for expansion on input and re-introduction on
99 /* Static attributes determined during input. */
101 - const char *text; /* the text of the word */
102 - int length; /* length of this word */
103 + const wchar_t *text; /* the text of the word */
104 + int length; /* length of this word, in characters */
105 + int width; /* width of this word, in columns */
106 int space; /* the size of the following space */
107 unsigned int paren:1; /* starts with open paren */
108 unsigned int period:1; /* ends in [.?!])* */
111 /* The remaining fields are computed during the optimization. */
113 - int line_length; /* length of the best line starting here */
114 + int line_width; /* width of the best line starting here */
115 COST best_cost; /* cost of best paragraph starting here */
116 WORD *next_break; /* break which achieves best_cost */
118 @@ -152,16 +173,16 @@
119 static void set_prefix (char *p);
120 static void fmt (FILE *f);
121 static bool get_paragraph (FILE *f);
122 -static int get_line (FILE *f, int c);
123 -static int get_prefix (FILE *f);
124 -static int get_space (FILE *f, int c);
125 -static int copy_rest (FILE *f, int c);
126 -static bool same_para (int c);
127 +static wint_t get_line (FILE *f, wint_t c);
128 +static wint_t get_prefix (FILE *f);
129 +static wint_t get_space (FILE *f, wint_t c);
130 +static wint_t copy_rest (FILE *f, wint_t c);
131 +static bool same_para (wint_t c);
132 static void flush_paragraph (void);
133 static void fmt_paragraph (void);
134 static void check_punctuation (WORD *w);
135 static COST base_cost (WORD *this);
136 -static COST line_cost (WORD *next, int len);
137 +static COST line_cost (WORD *next, int wid);
138 static void put_paragraph (WORD *finish);
139 static void put_line (WORD *w, int indent);
140 static void put_word (WORD *w);
142 /* If true, don't preserve inter-word spacing (default false). */
145 +/* How many spaces to put after a sentence (1 or 2). */
146 +static int sentence_space;
148 /* Prefix minus leading and trailing spaces (default ""). */
149 -static const char *prefix;
150 +static wchar_t *prefix;
152 /* User-supplied maximum line width (default WIDTH). The only output
153 lines longer than this will each comprise a single word. */
154 @@ -190,14 +214,14 @@
156 /* Values derived from the option values. */
158 -/* The length of prefix minus leading space. */
159 -static int prefix_full_length;
160 +/* The width of prefix minus leading space. */
161 +static int prefix_full_width;
163 -/* The length of the leading space trimmed from the prefix. */
164 +/* The width of the leading space trimmed from the prefix. */
165 static int prefix_lead_space;
167 -/* The length of prefix minus leading and trailing space. */
168 -static int prefix_length;
169 +/* The width of prefix minus leading and trailing space. */
170 +static int prefix_width;
172 /* The preferred width of text lines, set to LEEWAY % less than max_width. */
173 static int best_width;
174 @@ -212,10 +236,10 @@
176 /* Space for the paragraph text -- longer paragraphs are handled neatly
177 (cf. flush_paragraph()). */
178 -static char parabuf[MAXCHARS];
179 +static wchar_t parabuf[MAXCHARS];
181 /* A pointer into parabuf, indicating the first unused character position. */
183 +static wchar_t *wptr;
185 /* The words of a paragraph -- longer paragraphs are handled neatly
186 (cf. flush_paragraph()). */
187 @@ -247,16 +271,16 @@
188 prefix (next_prefix_indent). See get_paragraph() and copy_rest(). */
190 /* The last character read from the input file. */
191 -static int next_char;
192 +static wint_t next_char;
194 /* The space before the trimmed prefix (or part of it) on the next line
195 after the current paragraph. */
196 static int next_prefix_indent;
198 -/* If nonzero, the length of the last line output in the current
199 +/* If nonzero, the width of the last line output in the current
200 paragraph, used to charge for raggedness at the split point for long
201 paragraphs chosen by fmt_paragraph(). */
202 -static int last_line_length;
203 +static int last_line_width;
210 -t, --tagged-paragraph indentation of first line different from second\n\
211 - -u, --uniform-spacing one space between words, two after sentences\n\
212 + -u, --uniform-spacing one space between words, two between sentences\n\
213 + -n, --single-spaces single spaces between sentences\n\
214 -w, --width=WIDTH maximum line width (default of 75 columns)\n\
216 fputs (HELP_OPTION_DESCRIPTION, stdout);
218 {"split-only", no_argument, NULL, 's'},
219 {"tagged-paragraph", no_argument, NULL, 't'},
220 {"uniform-spacing", no_argument, NULL, 'u'},
221 + {"single-spaces", no_argument, NULL, 'n'},
222 {"width", required_argument, NULL, 'w'},
223 {GETOPT_HELP_OPTION_DECL},
224 {GETOPT_VERSION_OPTION_DECL},
226 atexit (close_stdout);
228 crown = tagged = split = uniform = false;
229 + sentence_space = 2;
232 - prefix_length = prefix_lead_space = prefix_full_length = 0;
234 + prefix_width = prefix_lead_space = prefix_full_width = 0;
236 if (argc > 1 && argv[1][0] == '-' && ISDIGIT (argv[1][1]))
242 - while ((optchar = getopt_long (argc, argv, "0123456789cstuw:p:",
243 + while ((optchar = getopt_long (argc, argv, "0123456789cstunw:p:",
252 + sentence_space = 1;
256 max_width_option = optarg;
258 @@ -436,26 +467,32 @@
261 /* Trim space from the front and back of the string P, yielding the prefix,
262 - and record the lengths of the prefix and the space trimmed. */
263 + and record the widths of the prefix and the space trimmed. */
272 prefix_lead_space = 0;
280 - prefix_full_length = strlen (p);
281 - s = p + prefix_full_length;
282 - while (s > p && s[-1] == ' ')
285 - prefix_length = s - p;
286 + len = mbsrtowcs (NULL, (const char **) &p, 0, NULL);
287 + prefix = xmalloc (len * sizeof (wchar_t));
288 + mbsrtowcs (prefix, (const char **) &p, len, NULL);
289 + for (s = prefix; *s; s++)
290 + prefix_full_width += xwcwidth (*s);
291 + prefix_width = prefix_full_width;
292 + while (s > prefix && s[-1] == L' ')
300 /* read file F and send formatted output to stdout. */
301 @@ -524,24 +561,24 @@
303 get_paragraph (FILE *f)
308 - last_line_length = 0;
309 + last_line_width = 0;
312 /* Scan (and copy) blank lines, and lines not introduced by the prefix. */
314 - while (c == '\n' || c == EOF
315 + while (c == L'\n' || c == WEOF
316 || next_prefix_indent < prefix_lead_space
317 - || in_column < next_prefix_indent + prefix_full_length)
318 + || in_column < next_prefix_indent + prefix_full_width)
320 c = copy_rest (f, c);
333 @@ -597,26 +634,26 @@
334 that failed to match the prefix. In the latter, C is \n or EOF.
335 Return the character (\n or EOF) ending the line. */
338 -copy_rest (FILE *f, int c)
340 +copy_rest (FILE *f, wint_t c)
346 - if (in_column > next_prefix_indent || (c != '\n' && c != EOF))
347 + if (in_column > next_prefix_indent || (c != L'\n' && c != WEOF))
349 put_space (next_prefix_indent);
350 for (s = prefix; out_column != in_column && *s; out_column++)
352 - if (c != EOF && c != '\n')
354 + if (c != WEOF && c != L'\n')
355 put_space (in_column - out_column);
356 - if (c == EOF && in_column >= next_prefix_indent + prefix_length)
358 + if (c == WEOF && in_column >= next_prefix_indent + prefix_width)
361 - while (c != '\n' && c != EOF)
362 + while (c != L'\n' && c != WEOF)
371 @@ -626,11 +663,11 @@
376 +same_para (wint_t c)
378 return (next_prefix_indent == prefix_indent
379 - && in_column >= next_prefix_indent + prefix_full_length
380 - && c != '\n' && c != EOF);
381 + && in_column >= next_prefix_indent + prefix_full_width
382 + && c != L'\n' && c != WEOF);
385 /* Read a line from input file F, given first non-blank character C
386 @@ -641,11 +678,11 @@
388 Return the first non-blank character of the next line. */
391 -get_line (FILE *f, int c)
393 +get_line (FILE *f, wint_t c)
396 - char *end_of_parabuf;
397 + wchar_t *end_of_parabuf;
400 end_of_parabuf = ¶buf[MAXCHARS];
404 word_limit->text = wptr;
405 + word_limit->width = 0;
408 if (wptr == end_of_parabuf)
409 @@ -665,10 +703,12 @@
414 + word_limit->width += xwcwidth (c);
417 - while (c != EOF && !isspace (c));
418 - in_column += word_limit->length = wptr - word_limit->text;
419 + while (c != WEOF && !isspace (c));
420 + word_limit->length = wptr - word_limit->text;
421 + in_column += word_limit->width;
422 check_punctuation (word_limit);
424 /* Scan inter-word space. */
425 @@ -676,11 +716,11 @@
427 c = get_space (f, c);
428 word_limit->space = in_column - start;
429 - word_limit->final = (c == EOF
430 + word_limit->final = (c == WEOF
431 || (word_limit->period
432 - && (c == '\n' || word_limit->space > 1)));
433 - if (c == '\n' || c == EOF || uniform)
434 - word_limit->space = word_limit->final ? 2 : 1;
435 + && (c == L'\n' || word_limit->space > 1)));
436 + if (c == L'\n' || c == WEOF || uniform)
437 + word_limit->space = word_limit->final ? sentence_space : 1;
438 if (word_limit == end_of_word)
440 set_other_indent (true);
441 @@ -688,34 +728,34 @@
445 - while (c != '\n' && c != EOF);
446 + while (c != L'\n' && c != WEOF);
447 return get_prefix (f);
450 /* Read a prefix from input file F. Return either first non-matching
451 character, or first non-blank character after the prefix. */
461 - c = get_space (f, getc (f));
462 - if (prefix_length == 0)
463 + c = get_space (f, xgetwc (f));
464 + if (prefix_width == 0)
465 next_prefix_indent = prefix_lead_space < in_column ?
466 prefix_lead_space : in_column;
471 next_prefix_indent = in_column;
472 - for (p = prefix; *p != '\0'; p++)
473 + for (p = prefix; *p != L'\0'; p++)
475 - unsigned char pc = *p;
483 c = get_space (f, c);
485 @@ -725,21 +765,21 @@
486 /* Read blank characters from input file F, starting with C, and keeping
487 in_column up-to-date. Return first non-blank character. */
490 -get_space (FILE *f, int c)
492 +get_space (FILE *f, wint_t c)
499 - else if (c == '\t')
500 + else if (c == L'\t')
503 in_column = (in_column / TABWIDTH + 1) * TABWIDTH;
514 check_punctuation (WORD *w)
516 - char const *start = w->text;
517 - char const *finish = start + (w->length - 1);
518 - unsigned char fin = *finish;
519 + wchar_t const *start = w->text;
520 + wchar_t const *finish = start + (w->length - 1);
521 + wchar_t fin = *finish;
523 w->paren = isopen (*start);
524 w->punct = !! ispunct (fin);
527 if (word_limit == word)
529 - fwrite (parabuf, sizeof *parabuf, wptr - parabuf, stdout);
531 + for (outptr = parabuf; outptr < wptr; outptr++)
532 + putwchar (*outptr);
537 /* Copy text of words down to start of parabuf -- we use memmove because
538 the source and target may overlap. */
540 - memmove (parabuf, split_point->text, wptr - split_point->text);
541 + memmove (parabuf, split_point->text,
542 + (wptr - split_point->text) * sizeof (wchar_t));
543 shift = split_point->text - parabuf;
546 @@ -830,53 +873,53 @@
556 word_limit->best_cost = 0;
557 - saved_length = word_limit->length;
558 - word_limit->length = max_width; /* sentinel */
559 + saved_width = word_limit->width;
560 + word_limit->width = max_width; /* sentinel */
562 for (start = word_limit - 1; start >= word; start--)
565 - len = start == word ? first_indent : other_indent;
566 + wid = start == word ? first_indent : other_indent;
568 /* At least one word, however long, in the line. */
577 /* Consider breaking before w. */
579 - wcost = line_cost (w, len) + w->best_cost;
580 - if (start == word && last_line_length > 0)
581 - wcost += RAGGED_COST (len - last_line_length);
582 + wcost = line_cost (w, wid) + w->best_cost;
583 + if (start == word && last_line_width > 0)
584 + wcost += RAGGED_COST (wid - last_line_width);
588 start->next_break = w;
589 - start->line_length = len;
590 + start->line_width = wid;
593 - /* This is a kludge to keep us from computing `len' as the
594 - sum of the sentinel length and some non-zero number.
595 - Since the sentinel w->length may be INT_MAX, adding
596 + /* This is a kludge to keep us from computing `wid' as the
597 + sum of the sentinel width and some non-zero number.
598 + Since the sentinel w->width may be INT_MAX, adding
599 to that would give a negative result. */
603 - len += (w - 1)->space + w->length; /* w > start >= word */
604 + wid += (w - 1)->space + w->width; /* w > start >= word */
606 - while (len < max_width);
607 + while (wid < max_width);
608 start->best_cost = best + base_cost (start);
611 - word_limit->length = saved_length;
612 + word_limit->width = saved_width;
615 /* Return the constant component of the cost of breaking before the
616 @@ -901,33 +944,33 @@
617 else if ((this - 1)->punct)
619 else if (this > word + 1 && (this - 2)->final)
620 - cost += WIDOW_COST ((this - 1)->length);
621 + cost += WIDOW_COST ((this - 1)->width);
626 else if (this->final)
627 - cost += ORPHAN_COST (this->length);
628 + cost += ORPHAN_COST (this->width);
633 /* Return the component of the cost of breaking before word NEXT that
634 - depends on LEN, the length of the line beginning there. */
635 + depends on WID, the width of the line beginning there. */
638 -line_cost (WORD *next, int len)
639 +line_cost (WORD *next, int wid)
644 if (next == word_limit)
646 - n = best_width - len;
647 + n = best_width - wid;
648 cost = SHORT_COST (n);
649 if (next->next_break != word_limit)
651 - n = len - next->line_length;
652 + n = wid - next->line_width;
653 cost += RAGGED_COST (n);
659 put_space (prefix_indent);
660 - fputs (prefix, stdout);
661 - out_column += prefix_length;
662 + fputws (prefix, stdout);
663 + out_column += prefix_width;
664 put_space (indent - out_column);
666 endline = w->next_break - 1;
668 put_space (w->space);
671 - last_line_length = out_column;
673 + last_line_width = out_column;
677 /* Output to stdout the word W. */
678 @@ -976,13 +1019,13 @@
687 for (n = w->length; n != 0; n--)
689 - out_column += w->length;
691 + out_column += w->width;
694 /* Output to stdout SPACE spaces, or equivalent tabs. */
695 @@ -999,13 +1042,13 @@
696 if (out_column + 1 < tab_target)
697 while (out_column < tab_target)
701 out_column = (out_column / TABWIDTH + 1) * TABWIDTH;
704 while (out_column < space_target)