aboutsummaryrefslogtreecommitdiffstats
path: root/figlet.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2012-05-08 14:52:05 +0100
committerJonathan McCrohan <jmccrohan@gmail.com>2012-05-08 14:52:05 +0100
commitdee0cd250574b52e74a9390f6f9c1efd818223d4 (patch)
treeab1a7eb424a8064088d3517ea1731ef22ad96a4d /figlet.c
parent1c0bc9c51fdc8c3d2350cae1706f990b480bf0bd (diff)
parent3a941f4ae2213f26118f5cfde03ca793b31ca838 (diff)
downloadfiglet-dee0cd250574b52e74a9390f6f9c1efd818223d4.tar.gz
Merge tag 'upstream/2.2.3'
Upstream version 2.2.3
Diffstat (limited to 'figlet.c')
-rw-r--r--figlet.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/figlet.c b/figlet.c
index d3bfbbb..e26d42b 100644
--- a/figlet.c
+++ b/figlet.c
@@ -3,16 +3,17 @@
FIGlet Copyright 1991, 1993, 1994 Glenn Chappell and Ian Chai
FIGlet Copyright 1996, 1997, 1998, 1999, 2000, 2001 John Cowan
FIGlet Copyright 2002 Christiaan Keet
+ FIGlet Copyright 2011 Claudio Matsuoka
Portions written by Paul Burton and Christiaan Keet
Internet: <info@figlet.org>
FIGlet, along with the various FIGlet fonts and documentation, is
- copyrighted under the provisions of the Academic Free License
+ copyrighted under the provisions of the New BSD License (3-clause)
(as listed in the file "LICENSE" which is included in this package)
****************************************************************************/
-#define DATE "05 July 2005"
-#define VERSION "2.2.2"
-#define VERSION_INT 20202
+#define DATE "12 January 2011"
+#define VERSION "2.2.3"
+#define VERSION_INT 20203
/* FIGlet (Frank, Ian & Glenn's Letters) */
/* by Glenn Chappell */
@@ -36,6 +37,7 @@
http://www.figlet.org/ */
/* Release 2.2.2 by Christiaan Keet: License changed from "Artistic License"
to "Academic Free License" as agreed by FIGlet authors. 05 July 2005 */
+/* Release 2.2.3 by Claudio Matsuoka, 12 January 2011 */
/*---------------------------------------------------------------------------
DEFAULTFONTDIR and DEFAULTFONTFILE should be defined in the Makefile.
@@ -62,6 +64,7 @@
#include <fcntl.h> /* Needed for get_columns */
#ifdef unix
+#include <unistd.h>
#include <sys/ioctl.h> /* Needed for get_columns */
#endif
@@ -655,7 +658,7 @@ char *controlname;
inchr firstch,lastch;
char dashcheck;
inchr offset;
- char *controlpath,magicnum[5];
+ char *controlpath;
int command;
ZFILE *controlfile;
int namelen;
@@ -1423,7 +1426,7 @@ int smushamt()
int addchar(c)
inchr c;
{
- int smushamount,row,k;
+ int smushamount,row,k,column,offset;
char *templine;
getletter(c);
@@ -1433,6 +1436,7 @@ inchr c;
return 0;
}
+ offset = 0;
templine = (char*)myalloc(sizeof(char)*(outlinelenlimit+1));
for (row=0;row<charheight;row++) {
if (right2left) {
@@ -1446,8 +1450,13 @@ inchr c;
}
else {
for (k=0;k<smushamount;k++) {
- outputline[row][outlinelen-smushamount+k] =
- smushem(outputline[row][outlinelen-smushamount+k],currchar[row][k]);
+ column = outlinelen-smushamount+k;
+ if (column < 0) {
+ offset = -column;
+ column = 0;
+ }
+ outputline[row][column] =
+ smushem(outputline[row][column],currchar[row][k + offset]);
}
strcat(outputline[row],currchar[row]+smushamount);
}
@@ -1532,6 +1541,7 @@ void splitline()
part1 = (inchr*)myalloc(sizeof(inchr)*(inchrlinelen+1));
part2 = (inchr*)myalloc(sizeof(inchr)*(inchrlinelen+1));
gotspace = 0;
+ lastspace = inchrlinelen-1;
for (i=inchrlinelen-1;i>=0;i--) {
if (!gotspace && inchrline[i]==' ') {
gotspace = 1;
@@ -1605,7 +1615,7 @@ inchr c;
int Agetchar()
{
extern int optind; /* current argv[] element under study */
- static AgetMode = 0; /* >= 0 for displacement into argv[n], <0 EOF */
+ static int AgetMode = 0; /* >= 0 for displacement into argv[n], <0 EOF */
char *arg; /* pointer to active character */
int c; /* current character */
@@ -1657,12 +1667,12 @@ inchr iso2022()
if (ch == 27) ch = Agetchar() + 0x100; /* ESC x */
if (ch == 0x100 + '$') ch = Agetchar() + 0x200; /* ESC $ x */
switch (ch) {
- case 14: /* invoke G0 into GL */
- gl = 0;
- return iso2022();
- case 15: /* invoke G1 into GL */
+ case 14: /* invoke G1 into GL */
gl = 1;
return iso2022();
+ case 15: /* invoke G0 into GL */
+ gl = 0;
+ return iso2022();
case 142: case 'N' + 0x100: /* invoke G2 into GL for next char */
save_gl = gl; save_gr = gr;
gl = gr = 2;
@@ -2029,5 +2039,5 @@ char *argv[];
if (outlinelen!=0) {
printline();
}
- exit(0);
+ return 0;
}