summaryrefslogtreecommitdiffstats
path: root/hack/hack.rip.c
diff options
context:
space:
mode:
authormycroft <mycroft@NetBSD.org>1993-04-20 21:27:31 +0000
committermycroft <mycroft@NetBSD.org>1993-04-20 21:27:31 +0000
commit398e51a3c905d11cf31c42e7bd5cce452bcd5534 (patch)
treee6054dce5f2a7fd92fd0410996e25db490b8c813 /hack/hack.rip.c
parentfe0afaaa1fcf50d1e1278bebfb8aacf7277dea01 (diff)
downloadbsdgames-darwin-398e51a3c905d11cf31c42e7bd5cce452bcd5534.tar.gz
bsdgames-darwin-398e51a3c905d11cf31c42e7bd5cce452bcd5534.tar.zst
bsdgames-darwin-398e51a3c905d11cf31c42e7bd5cce452bcd5534.zip
Don't modify string constants.
Diffstat (limited to 'hack/hack.rip.c')
-rw-r--r--hack/hack.rip.c79
1 files changed, 31 insertions, 48 deletions
diff --git a/hack/hack.rip.c b/hack/hack.rip.c
index bdc28230..7f729ba2 100644
--- a/hack/hack.rip.c
+++ b/hack/hack.rip.c
@@ -6,31 +6,26 @@
extern char plname[];
-static char *rip[] = {
-" ----------",
-" / \\",
-" / REST \\",
-" / IN \\",
-" / PEACE \\",
-" / \\",
-" | |",
-" | |",
-" | |",
-" | |",
-" | |",
-" | 1001 |",
-" *| * * * | *",
-" _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n",
-0
-};
+static char *riptop= "\
+ ----------\n\
+ / \\\n\
+ / REST \\\n\
+ / IN \\\n\
+ / PEACE \\\n\
+ / \\";
+
+static char *ripmid = " | %*s%*s |\n";
+
+static char *ripbot = "\
+ *| * * * | *\n\
+ _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______";
outrip(){
- register char **dp = rip;
- register char *dpx;
char buf[BUFSZ];
- register x,y;
cls();
+ curs(1, 8);
+ puts(riptop);
(void) strcpy(buf, plname);
buf[16] = 0;
center(6, buf);
@@ -42,40 +37,28 @@ outrip(){
index(vowels, *killer) ? " an" : " a");
center(8, buf);
(void) strcpy(buf, killer);
- if(strlen(buf) > 16) {
- register int i,i0,i1;
- i0 = i1 = 0;
- for(i = 0; i <= 16; i++)
- if(buf[i] == ' ') i0 = i, i1 = i+1;
- if(!i0) i0 = i1 = 16;
- buf[i1 + 16] = 0;
+ {
+ register int i1;
+ if((i1 = strlen(buf)) > 16) {
+ register int i,i0;
+ i0 = i1 = 0;
+ for(i = 0; i <= 16; i++)
+ if(buf[i] == ' ') i0 = i, i1 = i+1;
+ if(!i0) i0 = i1 = 16;
+ buf[i1 + 16] = 0;
+ buf[i0] = 0;
+ }
+ center(9, buf);
center(10, buf+i1);
- buf[i0] = 0;
}
- center(9, buf);
(void) sprintf(buf, "%4d", getyear());
center(11, buf);
- for(y=8; *dp; y++,dp++){
- x = 0;
- dpx = *dp;
- while(dpx[x]) {
- while(dpx[x] == ' ') x++;
- curs(x,y);
- while(dpx[x] && dpx[x] != ' '){
- extern int done_stopprint;
- if(done_stopprint)
- return;
- curx++;
- (void) putchar(dpx[x++]);
- }
- }
- }
+ puts(ripbot);
getret();
}
center(line, text) int line; char *text; {
-register char *ip,*op;
- ip = text;
- op = &rip[line][28 - ((strlen(text)+1)/2)];
- while(*ip) *op++ = *ip++;
+ register int n = strlen(text)/2;
+ printf(ripmid, 8+n, text, 8-n, "");
}
+