//---------------------------------------------------------------------- static void make_new_name(ushort name, ushort subnam, uchar mode, unsigned ip) { char str[MAXNAMELEN]; init_output_buffer(str, sizeof(str)); if ( fmtString(name, sizeof(str)-2, fmt_fullname) ) { trunc: trunc_name(ip, mode & 4); } else if ( (char)mode > 0 ) { register char *p = get_output_ptr(); if ( p >= &str[sizeof(str)-3] ) goto trunc; *p++ = '.'; set_output_ptr(p); if ( fmtString(subnam, &str[sizeof(str)-2] - p, fmt_name) ) goto trunc; } term_output_buffer(); do_name_anyway(ip, convert_clsname(str)); hide_name(ip); }
//---------------------------------------------------------------------- static int utfstr(ushort index, const ConstOpis *) { register int i; init_output_buffer(bufbeg, bufsize); i = fmtString(index, maxpos -= curpos, fmt_string, wrtutf); term_output_buffer(); maxpos += curpos; if(i < 0) return(0); qfprintf(myFile, "%s\n", bufbeg); return(++i); }
uchar OutUtf8(ushort index, fmt_t mode, color_t ntag) { register size_t size = (maxpos - curpos) - outcnt; if ( (int)size <= MIN_ARG_SIZE ) { DEB_ASSERT(((int)size < 0), "OutUtf8"); if ( (size = putLine/*outProc*/()) == 0) return(1 ); } if ( ntag) out_tagon(ntag ); ref_pos = get_output_ptr(); if ( fmtString(index, size, mode, /**outProc*/putLine) < 0) return(1 ); outcnt += get_output_ptr() - ref_pos; if ( ntag) out_tagoff(ntag ); return(0); }
uchar OutUtf8(ushort index, fmt_t mode, color_t color) { size_t size = (maxpos - curpos) - outcnt; if ( (int)size <= MIN_ARG_SIZE ) { DEB_ASSERT(((int)size < 0), "OutUtf8"); size = putLine(); if ( size == 0 ) return 1; } if ( color != COLOR_NONE ) out_tagon(color); ref_pos = get_output_ptr(); if ( fmtString(index, size, mode, putLine) < 0 ) return 1; outcnt += get_output_ptr() - ref_pos; if ( color != COLOR_NONE ) out_tagoff(color); return 0; }
void PluralFormatTest::pluralFormatExtendedTest(void) { const char *targets[] = { "There are no widgets.", "There is one widget.", "There is a bling widget and one other widget.", "There is a bling widget and 2 other widgets.", "There is a bling widget and 3 other widgets.", "Widgets, five (5-1=4) there be.", "There is a bling widget and 5 other widgets.", "There is a bling widget and 6 other widgets.", }; const char* fmt = "offset:1.0 " "=0 {There are no widgets.} " "=1.0 {There is one widget.} " "=5 {Widgets, five (5-1=#) there be.} " "one {There is a bling widget and one other widget.} " "other {There is a bling widget and # other widgets.}"; UErrorCode status = U_ZERO_ERROR; UnicodeString fmtString(fmt, -1, US_INV); PluralFormat pf(Locale::getEnglish(), fmtString, status); MessageFormat mf(UNICODE_STRING_SIMPLE("{0,plural,").append(fmtString).append((UChar)0x7d /* '}' */), Locale::getEnglish(), status); Formattable args; FieldPosition ignore; if (U_FAILURE(status)) { dataerrln("Failed to apply pattern - %s", u_errorName(status)); return; } for (int32_t i = 0; i < 7; ++i) { UnicodeString result = pf.format(i, status); if (U_FAILURE(status)) { errln("PluralFormat.format(value %d) failed - %s", i, u_errorName(status)); return; } UnicodeString expected(targets[i], -1, US_INV); if (expected != result) { UnicodeString message("PluralFormat.format(): Expected '", -1, US_INV); message.append(expected); message.append(UnicodeString("' but got '", -1, US_INV)); message.append(result); message.append("'", -1, US_INV); errln(message); } args.setLong(i); mf.format(&args, 1, result.remove(), ignore, status); if (U_FAILURE(status)) { errln("MessageFormat.format(value %d) failed - %s", i, u_errorName(status)); return; } if (expected != result) { UnicodeString message("MessageFormat.format(): Expected '", -1, US_INV); message.append(expected); message.append(UnicodeString("' but got '", -1, US_INV)); message.append(result); message.append("'", -1, US_INV); errln(message); } } }
std::string getResultMessage(result_t hr) { static const char *s_errors[] = { "", // CALL_E_BADPARAMCOUNT "Invalid number of parameters.", // CALL_E_PARAMNOTOPTIONAL "Parameter not optional.", // CALL_E_BADVARTYPE "The input parameter is not a valid type.", // CALL_E_INVALIDARG "Invalid argument.", // CALL_E_TYPEMISMATCH "The argument could not be coerced to the specified type.", // CALL_E_OUTRANGE "Value is out of range.", // CALL_E_CONSTRUCTOR "Constructor cannot be called as a function.", // CALL_E_NOTINSTANCE "Object is not an instance of declaring class.", // CALL_E_INVALID_CALL "Invalid procedure call.", // CALL_E_REENTRANT_CALL "Re-entrant calls are not allowed.", // CALL_E_INVALID_DATA "Invalid input data.", // CALL_E_BADINDEX "Index was out of range.", // CALL_E_OVERFLOW "Memory overflow error.", // CALL_E_EMPTY "Collection is empty.", // CALL_E_PENDDING "Operation now in progress.", // CALL_E_NOSYNC "Operation not support synchronous call.", // CALL_E_NOASYNC "Operation not support asynchronous call.", // CALL_E_INTERNAL "Internal error.", // CALL_E_RETURN_TYPE "Invalid return type.", // CALL_E_EXCEPTION "Exception occurred.", // CALL_E_JAVASCRIPT "Javascript error." }; if (hr == CALL_E_EXCEPTION) { std::string s = Runtime::errMessage(); if (s.length() > 0) return s; } if (hr > CALL_E_MIN && hr < CALL_E_MAX) return fmtString(hr, s_errors[CALL_E_MAX - hr]); hr = -hr; #ifdef _WIN32 WCHAR MsgBuf[1024]; if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MsgBuf, 1024, NULL )) { std::string s = fmtString(hr, UTF8_A(MsgBuf)); return s; } return fmtString(hr, "Unknown error."); #else return fmtString(hr, strerror(hr)); #endif }