Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -e option: Interrupt via Ctrl+C, Proper Makefile, and Cleanup sl.h #17

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#==========================================
# Makefile: makefile for sl 5.1
# Makefile: makefile for sl 6.0
# Copyright 1993, 1998, 2014
# Toyoda Masashi
# (mtoyoda@acm.org)
# Last Modified: 2014/03/31
# Last Modified: 2014/06/16
#==========================================

CC=gcc
CFLAGS=-O

sl: sl.c sl.h
$(CC) $(CFLAGS) -o sl sl.c -lncurses

install:
gzip -9 -f sl.1
install -D -m 0775 sl /usr/bin/sl
install -Dm 644 sl.1.gz /usr/share/man/man1/sl.1.gz

uninstall:
rm -rf /usr/bin/sl
rm -rf /usr/share/man/man1/sl.1.gz

clean:
rm -rf sl
7 changes: 5 additions & 2 deletions sl.1
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
.\"
.\" @(#)sl.1
.\"
.TH SL 1 "March 31, 2014"
.TH SL 1 "June 16, 2014"
.SH NAME
sl \- cure your bad habit of mistyping
.SH SYNOPSIS
.B sl
[
.B \-alFc
.B \-alFce
]
.SH DESCRIPTION
.B sl
Expand All @@ -27,6 +27,9 @@ It flies like the galaxy express 999.
.TP
.B \-c
C51 appears instead of D51.
.TP
.B \-e
Allow interrupt by Ctrl+C.
.PP
.SH SEE ALSO
.BR ls (1)
Expand Down
2 changes: 1 addition & 1 deletion sl.1.ja
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.\" (mtoyoda@acm.org)
.\" @(#)sl.1
.\"
.TH SL 1 "March 31, 2014"
.TH SL 1 "June 16, 2014"
.SH 名称
sl \- キータイプを矯正します。
.SH 形式
Expand Down
22 changes: 10 additions & 12 deletions sl.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/*========================================
* sl.c: SL version 5.02
* sl.c: SL version 6.00
* Copyright 1993,1998,2014
* Toyoda Masashi
* (mtoyoda@acm.org)
* Last Modified: 2014/06/03
* Last Modified: 2014/06/16
*========================================
*/
/* sl version 6.00 : add -e option */
/* by Hiroyuki Yamamoto 2014/06/16 */
/* sl version 5.02 : Fix compiler warnings. */
/* by Jeff Schwab 2014/06/03 */
/* sl version 5.01 : removed cursor and handling of IO */
Expand Down Expand Up @@ -41,18 +43,11 @@
#include <unistd.h>
#include "sl.h"

void add_smoke(int y, int x);
void add_man(int y, int x);
int add_C51(int x);
int add_D51(int x);
int add_sl(int x);
void option(char *str);
int my_mvaddstr(int y, int x, char *str);

int ACCIDENT = 0;
int LOGO = 0;
int FLY = 0;
int C51 = 0;
int INTR = 0;

int my_mvaddstr(int y, int x, char *str)
{
Expand All @@ -73,6 +68,7 @@ void option(char *str)
case 'F': FLY = 1; break;
case 'l': LOGO = 1; break;
case 'c': C51 = 1; break;
case 'e': INTR = 1; break;
default: break;
}
}
Expand All @@ -88,7 +84,10 @@ int main(int argc, char *argv[])
}
}
initscr();
signal(SIGINT, SIG_IGN);
if (INTR == 0) {
signal(SIGINT, SIG_IGN);
}
signal(SIGTSTP, SIG_IGN);
noecho();
curs_set(0);
nodelay(stdscr, TRUE);
Expand All @@ -113,7 +112,6 @@ int main(int argc, char *argv[])
endwin();
}


int add_sl(int x)
{
static char *sl[LOGOPATTERNS][LOGOHIGHT + 1]
Expand Down
19 changes: 16 additions & 3 deletions sl.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
/*========================================
* sl.h: SL version 5.02
* sl.h: SL version 6.00
* Copyright 1993,2002,2014
* Toyoda Masashi
* (mtoyoda@acm.org)
* Last Modified: 2014/06/03
* Last Modified: 2014/06/16
*========================================
*/

#ifndef SL_H
#define SL_H

/* Function Prototypes */
void add_smoke(int y, int x);
void add_man(int y, int x);
int add_C51(int x);
int add_D51(int x);
int add_sl(int x);
void option(char *str);
int my_mvaddstr(int y, int x, char *str);

#define D51HIGHT 10
#define D51FUNNEL 7
#define D51LENGTH 83
#define D51PATTERNS 6


#define D51STR1 " ==== ________ ___________ "
#define D51STR2 " _D _| |_______/ \\__I_I_____===__|_________| "
#define D51STR3 " |(_)--- | H\\________/ | | =|___ ___| "
Expand Down Expand Up @@ -148,3 +159,5 @@
#define C51WH12 "------'|oOo|=[]=- || || | ||=======_|__"
#define C51WH13 "/~\\____|___|/~\\_| O=======O=======O |__|+-/~\\_| "
#define C51WH14 "\\_/ \\_/ \\____/ \\____/ \\____/ \\_/ "

#endif /* SL_H */