char *libmail_str_sizekb(unsigned long n, char *sizebuf) { /* If size is less than 1K bytes, display it as 0.xK */ if (n < 1024) { strcpy(sizebuf, "0."); cat_n(sizebuf, (int)(10 * n / 1024 )); strcat(sizebuf, "K"); } /* If size is less than 1 meg, display is as xK */ else if (n < 1024 * 1024) { *sizebuf=0; cat_n(sizebuf, (unsigned long)(n+512)/1024); strcat(sizebuf, "K"); } /* Otherwise, display in megabytes */ else { unsigned long nm=(double)n / (1024.0 * 1024.0) * 10; *sizebuf=0; cat_n( sizebuf, nm / 10); strcat(sizebuf, "."); cat_n( sizebuf, nm % 10); strcat(sizebuf, "M"); } return (sizebuf); }
void LibRnrsUnicode::CharGeneralCategory::func(KevesVM* vm, const_KevesIterator pc) { KevesChar chr(vm->acc_); const char* cat[] { "XX", "Mn", "Mc", "Me", "Nd", "Nl", "No", "Zs", "Zp", "Zl", "Cc", "Cf", "Cs", "Co", "Cn", "Lu", "Ll", "Lt", "Lm", "Lo", "Pc", "Pd", "Ps", "Pe", "Pi", "Pf", "Po", "Sm", "Sc", "Sk", "So", }; QChar::Category cat_n(chr.category()); StringKevWithArray<0x4> cat_str(cat[cat_n]); SymbolKev cat_sym(cat_str); vm->acc_ = &cat_sym; return KevesVM::returnValueSafe(vm, pc); }