forked from github/server
commit
8bd7a0a157
|
@ -2025,10 +2025,10 @@ int entertain_cmd(unit * u, struct order *ord, econ_request **io_req)
|
|||
return 0;
|
||||
}
|
||||
|
||||
wants = u->number * (entertainbase + effskill(u, SK_ENTERTAINMENT, NULL) * entertainperlevel);
|
||||
max_e = getuint();
|
||||
if (max_e != 0 && wants > max_e) {
|
||||
wants = max_e;
|
||||
wants = getuint();
|
||||
max_e = u->number * (entertainbase + effskill(u, SK_ENTERTAINMENT, NULL) * entertainperlevel);
|
||||
if (wants > 0 && wants < max_e) {
|
||||
max_e = wants;
|
||||
}
|
||||
if (max_e > 0) {
|
||||
add_request(req++, ECON_ENTERTAIN, u, ord, max_e);
|
||||
|
|
|
@ -565,8 +565,8 @@ int autoseed(newfaction ** players, int nsize, int max_agediff)
|
|||
nfp = &nextf->next;
|
||||
while (*nfp) {
|
||||
newfaction *nf = *nfp;
|
||||
if (strcmp(nextf->email, nf->email) == 0) {
|
||||
log_warning("Duplicate email %s\n", nf->email?nf->email:"");
|
||||
if (nf->email && nextf->email && strcmp(nextf->email, nf->email) == 0) {
|
||||
log_warning("Duplicate email %s\n", nf->email ? nf->email : "");
|
||||
*nfp = nf->next;
|
||||
free_newfaction(nf);
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ void free_recruitments(recruitment * recruits)
|
|||
recruitment *rec = recruits;
|
||||
recruits = rec->next;
|
||||
free_requests(rec->requests);
|
||||
free(rec);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <wctype.h>
|
||||
#include <ctype.h>
|
||||
|
@ -33,6 +34,14 @@
|
|||
#define B00000011 0x03
|
||||
#define B00000001 0x01
|
||||
|
||||
static bool char_trimmed(wint_t wc) {
|
||||
if (wc >= 0x2000 && wc <= 0x200f) {
|
||||
/* only weird stuff here */
|
||||
return true;
|
||||
}
|
||||
return iswspace(wc) || iswcntrl(wc);
|
||||
}
|
||||
|
||||
size_t unicode_utf8_trim(char *buf)
|
||||
{
|
||||
int result = 0, ts = 0;
|
||||
|
@ -56,15 +65,15 @@ size_t unicode_utf8_trim(char *buf)
|
|||
++result;
|
||||
}
|
||||
}
|
||||
if (op == buf && (iswspace(wc) || !iswprint(wc))) {
|
||||
if (op == buf && char_trimmed(wc)) {
|
||||
result += size;
|
||||
}
|
||||
else if (wc>255 || !iscntrl(wc)) {
|
||||
else if (wc>255 || !iswcntrl(wc)) {
|
||||
if (op != ip) {
|
||||
memmove(op, ip, size);
|
||||
}
|
||||
op += size;
|
||||
if (iswspace(wc) || !iswprint(wc)) {
|
||||
if (char_trimmed(wc)) {
|
||||
ts += size;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -173,12 +173,23 @@ static void test_unicode_trim_ltrm(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
static void test_unicode_trim_emoji(CuTest *tc) {
|
||||
const char clock[] = { 0xE2, 0x8F, 0xB0, 0x00 };
|
||||
char name[64];
|
||||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%s Alarm%sClock %s", clock, clock, clock);
|
||||
strcpy(expect, name);
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
CuSuite *get_unicode_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_unicode_trim);
|
||||
SUITE_ADD_TEST(suite, test_unicode_trim_zwnj);
|
||||
SUITE_ADD_TEST(suite, test_unicode_trim_ltrm);
|
||||
SUITE_ADD_TEST(suite, test_unicode_trim_emoji);
|
||||
SUITE_ADD_TEST(suite, test_unicode_utf8_to_other);
|
||||
SUITE_ADD_TEST(suite, test_unicode_utf8_to_ucs);
|
||||
SUITE_ADD_TEST(suite, test_unicode_compare);
|
||||
|
|
Loading…
Reference in New Issue