mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-11 23:36:44 +01:00
truncater: typo in doc + renaming of varibles x and nx
This commit is contained in:
parent
4cfde927f3
commit
4ff170065c
1 changed files with 10 additions and 10 deletions
|
@ -15,7 +15,7 @@
|
||||||
#define STDIN 0
|
#define STDIN 0
|
||||||
|
|
||||||
/* The number of columns on the current line */
|
/* The number of columns on the current line */
|
||||||
static int x = 0;
|
static int col = 0;
|
||||||
|
|
||||||
/* Escape sequence state */
|
/* Escape sequence state */
|
||||||
static int esc = 0;
|
static int esc = 0;
|
||||||
|
@ -30,7 +30,7 @@ int toInt(String string);
|
||||||
/* Mane method!
|
/* Mane method!
|
||||||
* The only argument, in addition to the executed file,
|
* The only argument, in addition to the executed file,
|
||||||
* should be the width of the terminal which you get by
|
* should be the width of the terminal which you get by
|
||||||
* adding <code>`tput cols || echo 0`</code> as and argument.
|
* adding <code>`tput cols || echo 0`</code> as an argument.
|
||||||
*
|
*
|
||||||
* @param argc The number of startup arguments
|
* @param argc The number of startup arguments
|
||||||
* @param argv The startup arguments, the first is the file itself
|
* @param argv The startup arguments, the first is the file itself
|
||||||
|
@ -61,13 +61,13 @@ void main(int argc, String* argv)
|
||||||
void write(char b, int width)
|
void write(char b, int width)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char nx;
|
char tabstop;
|
||||||
|
|
||||||
if (esc == 0)
|
if (esc == 0)
|
||||||
{
|
{
|
||||||
if (b == '\n')
|
if (b == '\n')
|
||||||
{
|
{
|
||||||
if (x >= width)
|
if (col >= width)
|
||||||
{
|
{
|
||||||
/* Reset background colour */
|
/* Reset background colour */
|
||||||
write('\e', width);
|
write('\e', width);
|
||||||
|
@ -76,13 +76,13 @@ void write(char b, int width)
|
||||||
write('9', width);
|
write('9', width);
|
||||||
write('m', width);
|
write('m', width);
|
||||||
}
|
}
|
||||||
x = -1;
|
col = -1;
|
||||||
}
|
}
|
||||||
else if (b == '\t')
|
else if (b == '\t')
|
||||||
{
|
{
|
||||||
/* Tab to next pos ≡₈ 0 */
|
/* Tab to next pos ≡₈ 0 */
|
||||||
nx = 8 - (x & 7);
|
tabstop = 8 - (col & 7);
|
||||||
for (i = 0; i < nx; i++)
|
for (i = 0; i < tabstop; i++)
|
||||||
write(' ', width);
|
write(' ', width);
|
||||||
return; /* (!) */
|
return; /* (!) */
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ void write(char b, int width)
|
||||||
else if (esc == 1)
|
else if (esc == 1)
|
||||||
{
|
{
|
||||||
if (b == '[') esc = 2; /* CSI: CSI ends with a letter, m is for colour */
|
if (b == '[') esc = 2; /* CSI: CSI ends with a letter, m is for colour */
|
||||||
else if (b == ']') esc = 3; /* OSI: OSI P is for palett editing in Linux VT */
|
else if (b == ']') esc = 3; /* OSI: OSI P is for palette editing in Linux VT */
|
||||||
else esc = 10; /* Nothing to see here, move along */
|
else esc = 10; /* Nothing to see here, move along */
|
||||||
}
|
}
|
||||||
else if (esc == 2)
|
else if (esc == 2)
|
||||||
|
@ -118,14 +118,14 @@ void write(char b, int width)
|
||||||
within bounds ∨
|
within bounds ∨
|
||||||
∨ escape sequence ∨
|
∨ escape sequence ∨
|
||||||
∨ last with printed ∧ not first byte in character */
|
∨ last with printed ∧ not first byte in character */
|
||||||
(x < width) ||
|
(col < width) ||
|
||||||
(esc != 0) ||
|
(esc != 0) ||
|
||||||
(ok && ((b & 0xC0) == 0x80)))
|
(ok && ((b & 0xC0) == 0x80)))
|
||||||
{
|
{
|
||||||
printf("%c", b);
|
printf("%c", b);
|
||||||
if ((esc == 0) && ((b & 0xC0) != 0x80))
|
if ((esc == 0) && ((b & 0xC0) != 0x80))
|
||||||
/* Count up columns of not in escape sequnce and */
|
/* Count up columns of not in escape sequnce and */
|
||||||
x++; /* the byte is not the first byte in the character */
|
col++; /* the byte is not the first byte in the character */
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue