slackbuilds/games/xtetris/patches/score_hostname.diff

31 lines
1.1 KiB
Diff

diff -Naur xtetris-2.6/score.c xtetris-2.6.patched/score.c
--- xtetris-2.6/score.c 1992-10-19 14:44:41.000000000 -0400
+++ xtetris-2.6.patched/score.c 2024-11-28 12:53:12.047333518 -0500
@@ -17,7 +17,7 @@
long when;
extern char *ctime();
extern long time();
- char hostname[BUFSIZ];
+ char hostname[12];
char buf[BUFSIZ];
char padname[25];
@@ -58,10 +58,15 @@
high_scores[i].score = score;
high_scores[i].rows = rows;
high_scores[i].level = rows / 10;
- if (_XGetHostname(hostname, BUFSIZ) == -1)
+ if (_XGetHostname(hostname, 12) == -1)
strncpy(high_scores[i].hostname, "unknown-host",sizeof(high_scores[i].hostname)-1);
- else
+ else {
+ char *htmp = strchr(hostname, '.');
+ /* fprintf(stderr, "hostname was '%s'\n", hostname); */
+ if(htmp) *htmp = '\0';
+ /* fprintf(stderr, "hostname now '%s'\n", hostname); */
strncpy(high_scores[i].hostname, hostname,sizeof(high_scores[i].hostname)-1);
+ }
high_scores[i].hostname[sizeof(high_scores[i].hostname)-1] = 0;
time(&when);
strncpy(high_scores[i].date, ctime(&when), 24);