Deleted Added
full compact
20a21
> #define LINENUM_WIDTH 8 /* Chars to use for line number */
34a36
> static int lmargin; /* Left margin */
46a49
> extern int status_col;
53a57,58
> extern POSITION start_attnpos;
> extern POSITION end_attnpos;
76a82,86
> lmargin = 0;
> if (status_col)
> lmargin += 1;
> if (linenums == OPT_ONPLUS)
> lmargin += LINENUM_WIDTH+1;
88d97
< register int n;
89a99,111
> if (linenums == OPT_ONPLUS)
> {
> /*
> * Get the line number and put it in the current line.
> * {{ Note: since find_linenum calls forw_raw_line,
> * it may seek in the input file, requiring the caller
> * of plinenum to re-seek if necessary. }}
> * {{ Since forw_raw_line modifies linebuf, we must
> * do this first, before storing anything in linebuf. }}
> */
> lno = find_linenum(pos);
> }
>
91,92c113
< * We display the line number at the start of each line
< * only if the -N option is set.
---
> * Display a status column if the -J option is set.
94,96c115,125
< if (linenums != OPT_ONPLUS)
< return;
<
---
> if (status_col)
> {
> linebuf[curr] = ' ';
> if (start_attnpos != NULL_POSITION &&
> pos >= start_attnpos && pos < end_attnpos)
> attr[curr] = AT_STANDOUT;
> else
> attr[curr] = 0;
> curr++;
> column++;
> }
98,101c127,128
< * Get the line number and put it in the current line.
< * {{ Note: since find_linenum calls forw_raw_line,
< * it may seek in the input file, requiring the caller
< * of plinenum to re-seek if necessary. }}
---
> * Display the line number at the start of each line
> * if the -N option is set.
103,110c130,136
< lno = find_linenum(pos);
<
< sprintf(&linebuf[curr], "%6d", lno);
< n = strlen(&linebuf[curr]);
< column += n;
< for (i = 0; i < n; i++)
< attr[curr++] = 0;
<
---
> if (linenums == OPT_ONPLUS)
> {
> sprintf(&linebuf[curr], "%*d", LINENUM_WIDTH, lno);
> column += LINENUM_WIDTH;
> for (i = 0; i < LINENUM_WIDTH; i++)
> attr[curr++] = 0;
> }
112,114c138
< * Append enough spaces to bring us to the next tab stop.
< * {{ We could avoid this at the cost of adding some
< * complication to the tab stop logic in pappend(). }}
---
> * Append enough spaces to bring us to the lmargin.
116,118c140
< if (tabstop == 0)
< tabstop = 1;
< do
---
> while (column < lmargin)
123c145
< } while (((column + cshift) % tabstop) != 0);
---
> }
160,163c182,185
< if (shift > column)
< shift = column;
< if (shift > curr)
< shift = curr;
---
> if (shift > column - lmargin)
> shift = column - lmargin;
> if (shift > curr - lmargin)
> shift = curr - lmargin;
169c191
< real_shift = utf_len(linebuf, shift);
---
> real_shift = utf_len(linebuf + lmargin, shift);
175,176c197,198
< linebuf[i] = linebuf[i + real_shift];
< attr[i] = attr[i + real_shift];
---
> linebuf[lmargin + i] = linebuf[lmargin + i + real_shift];
> attr[lmargin + i] = attr[lmargin + i + real_shift];
477c499
< } while (((column + cshift) % tabstop) != 0);
---
> } while (((column + cshift - lmargin) % tabstop) != 0);