such.
(ufindbreak, ufindpfx): Rename, move to pr.c, external linkage.
extern void pr_beep(void);
extern void mpr(int, s_char *, ...) ATTRIBUTE((format (printf, 2, 3)));
extern void prtoascii(char *buf /* buf is message text */);
+extern int ufindpfx(char *, int);
/* radmap.c */
extern int deltx(struct range *, coord);
#include "file.h"
#include "commands.h"
-static int ufindbreak(char *message /* message is message text */,
- int num_chars);
-
int
flash(void)
{
char c; /* c is message text */
int pos;
- pos = ufindbreak(message, 60);
+ pos = ufindpfx(message, 60);
c = message[pos];
if (c)
message[pos] = '\0';
}
return 0;
}
-
-/*
- * Return byte-index of the N-th UTF-8 character in UTF-8 string S.
- * If S doesn't have that many characters, return its length instead.
- */
-int
-ufindbreak(char *s /* s is message text */, int n)
-{
- int i = 0;
-
- while (n && s[i])
- {
- if ((s[i++] & 0xc0) == 0xc0)
- while ((s[i] & 0xc0) == 0x80)
- i++;
- --n;
- }
- return i;
-}
play_list(struct player *joe)
{
time_t now;
- s_char *com;
+ char com[1 + 6*20 + 2]; /* user text */
struct natstr *natp;
struct natstr *us;
+ int n;
if (joe->cnum >= MAXNOC || !(natp = getnatp(joe->cnum)))
return 0;
}
time(&now);
- if (player->god) {
- if (!joe->combuf || !*joe->combuf)
- com = "NULL";
- else
- com = joe->combuf;
- } else
- com = "";
-
-
- pr("%-9.9s %3d %32.32s %2d:%02d %4lds %-20.20s\n",
+ pr("%-9.9s %3d %32.32s %2d:%02d %4lds",
cname(joe->cnum),
joe->cnum,
player->god || joe->cnum == player->cnum ? praddr(joe) : "",
natp->nat_minused / 60,
natp->nat_minused % 60,
- (long)(now - joe->curup),
- com);
+ (long)(now - joe->curup));
+
+ if (player->god) {
+ if (!joe->combuf || !*joe->combuf)
+ pr(" NULL\n");
+ else {
+ n = ufindpfx(joe->combuf, 20);
+ if (CANT_HAPPEN(n + 3u > sizeof(com))) {
+ pr(" BUGGY\n");
+ return 1;
+ }
+ sprintf(com, " %.*s\n", n, joe->combuf);
+ uprnf(com);
+ }
+ } else
+ pr("\n");
+
return 1;
}
pbuf--;
}
}
+
+/*
+ * Return byte-index of the N-th UTF-8 character in UTF-8 string S.
+ * If S doesn't have that many characters, return its length instead.
+ */
+int
+ufindpfx(char *s, int n)
+{
+ int i = 0;
+
+ while (n && s[i])
+ {
+ if ((s[i++] & 0xc0) == 0xc0)
+ while ((s[i] & 0xc0) == 0x80)
+ i++;
+ --n;
+ }
+ return i;
+}