diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-07-21 14:03:55 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-07-21 14:03:55 +0200 |
commit | 4ff170065c649a6f34da55c3e2a426f38259227a (patch) | |
tree | ced28f38e413a03174bef283075546aabed8d3b4 | |
parent | 4cfde927f3dd456d2c4315f7eca6fe65c0f3351f (diff) | |
download | ponysay-4ff170065c649a6f34da55c3e2a426f38259227a.tar.gz ponysay-4ff170065c649a6f34da55c3e2a426f38259227a.tar.bz2 ponysay-4ff170065c649a6f34da55c3e2a426f38259227a.zip |
truncater: typo in doc + renaming of varibles x and nx
-rw-r--r-- | ponysaytruncater.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ponysaytruncater.c b/ponysaytruncater.c index 58f3d91..d703406 100644 --- a/ponysaytruncater.c +++ b/ponysaytruncater.c @@ -15,7 +15,7 @@ #define STDIN 0 /* The number of columns on the current line */ -static int x = 0; +static int col = 0; /* Escape sequence state */ static int esc = 0; @@ -30,7 +30,7 @@ int toInt(String string); /* Mane method! * The only argument, in addition to the executed file, * 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 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) { int i; - char nx; + char tabstop; if (esc == 0) { if (b == '\n') { - if (x >= width) + if (col >= width) { /* Reset background colour */ write('\e', width); @@ -76,13 +76,13 @@ void write(char b, int width) write('9', width); write('m', width); } - x = -1; + col = -1; } else if (b == '\t') { /* Tab to next pos ≡₈ 0 */ - nx = 8 - (x & 7); - for (i = 0; i < nx; i++) + tabstop = 8 - (col & 7); + for (i = 0; i < tabstop; i++) write(' ', width); return; /* (!) */ } @@ -92,7 +92,7 @@ void write(char b, int width) else if (esc == 1) { 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 if (esc == 2) @@ -118,14 +118,14 @@ void write(char b, int width) within bounds ∨ ∨ escape sequence ∨ ∨ last with printed ∧ not first byte in character */ - (x < width) || + (col < width) || (esc != 0) || (ok && ((b & 0xC0) == 0x80))) { printf("%c", b); if ((esc == 0) && ((b & 0xC0) != 0x80)) /* 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; } else |