static PyObject* PyLocale_localeconv(PyObject* self) { PyObject* result; struct lconv *l; PyObject *x; result = PyDict_New(); if (!result) return NULL; /* if LC_NUMERIC is different in the C library, use saved value */ l = localeconv(); /* hopefully, the localeconv result survives the C library calls involved herein */ #define RESULT(key, obj)\ do { \ if (obj == NULL) \ goto failed; \ if (PyDict_SetItemString(result, key, obj) < 0) { \ Py_DECREF(obj); \ goto failed; \ } \ Py_DECREF(obj); \ } while (0) #define RESULT_STRING(s)\ do { \ x = PyUnicode_DecodeLocale(l->s, NULL); \ RESULT(#s, x); \ } while (0) #define RESULT_INT(i)\ do { \ x = PyLong_FromLong(l->i); \ RESULT(#i, x); \ } while (0) /* Numeric information */ RESULT_STRING(decimal_point); RESULT_STRING(thousands_sep); x = copy_grouping(l->grouping); RESULT("grouping", x); /* Monetary information */ RESULT_STRING(int_curr_symbol); RESULT_STRING(currency_symbol); RESULT_STRING(mon_decimal_point); RESULT_STRING(mon_thousands_sep); x = copy_grouping(l->mon_grouping); RESULT("mon_grouping", x); RESULT_STRING(positive_sign); RESULT_STRING(negative_sign); RESULT_INT(int_frac_digits); RESULT_INT(frac_digits); RESULT_INT(p_cs_precedes); RESULT_INT(p_sep_by_space); RESULT_INT(n_cs_precedes); RESULT_INT(n_sep_by_space); RESULT_INT(p_sign_posn); RESULT_INT(n_sign_posn); return result; failed: Py_XDECREF(result); return NULL; }
void STDCALL name params \ { \ HINSTANCE __hInst = GetDirectEngine(); \ void *func; \ if(__hInst) \ { \ func = GetProcAddress(__hInst, #name); \ if(func) \ { \ (*((void (*) params)func)) args; \ } \ } \ } COR_PASS_THROUGH(HRESULT, CoInitializeEE, (DWORD fFlags), (fFlags), RESULT(E_NOTIMPL)) COR_PASS_THROUGH_VOID(CoUninitializeEE, (BOOL fFlags), (fFlags)) COR_PASS_THROUGH(BOOL, _CorDllMain, (HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved), (hInst, dwReason, lpReserved), 0) COR_PASS_THROUGH(__int32, _CorExeMain2, (PBYTE pUnmappedPE, DWORD cUnmappedPE, LPWSTR pImageNameIn, LPWSTR pLoadersFileName, LPWSTR pCmdLine), (pUnmappedPE, cUnmappedPE, pImageNameIn, pLoadersFileName, pCmdLine), 0) COR_PASS_THROUGH(HRESULT, _CorValidateImage, (PVOID *ImageBase, LPCSTR FileName), (ImageBase, FileName), RESULT(E_NOTIMPL)) COR_PASS_THROUGH_VOID(_CorImageUnloading, (PVOID ImageBase), (ImageBase)) COR_PASS_THROUGH(HRESULT, CoInitializeCor,
int main (void) { RESULT(checkit ("<%d>\n", 0x12345678)); RESULT(printf ("<%d>\n", 0x12345678)); RESULT(checkit ("<%200d>\n", 5)); RESULT(printf ("<%200d>\n", 5)); RESULT(checkit ("<%.300d>\n", 6)); RESULT(printf ("<%.300d>\n", 6)); RESULT(checkit ("<%100.150d>\n", 7)); RESULT(printf ("<%100.150d>\n", 7)); RESULT(checkit ("<%s>\n", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\ 777777777777777777333333333333366666666666622222222222777777777777733333")); RESULT(printf ("<%s>\n", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\ 777777777777777777333333333333366666666666622222222222777777777777733333")); RESULT(checkit ("<%f><%0+#f>%s%d%s>\n", 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx")); RESULT(printf ("<%f><%0+#f>%s%d%s>\n", 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx")); RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI)); RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI)); RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI)); RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI)); RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n", 75, 75, 75, 75, 75, 75, 75)); RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n", 75, 75, 75, 75, 75, 75, 75)); RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n", 75, 75, 75, 75, 75, 75, 75)); RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n", 75, 75, 75, 75, 75, 75, 75)); RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456)); RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456)); #if defined(__GNUC__) || defined (HAVE_LONG_LONG) RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345)); RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345)); RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345)); RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345)); #endif #if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE) RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n", 1.23456, 1.234567890123456789L, 1.23456)); RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n", 1.23456, 1.234567890123456789L, 1.23456)); #endif return 0; }
static VALUE Lambert_Wm1_e(VALUE self, VALUE x) { int ret; gsl_sf_result r; ret = gsl_sf_lambert_Wm1_e(NUM2DBL(x), &r); return RESULT(&r); }
static VALUE Airy_Bi_deriv_e(VALUE self, VALUE x, VALUE mode) { int ret; gsl_sf_result r; ret = gsl_sf_airy_Bi_deriv_e(NUM2DBL(x), NUM2UINT(mode), &r); return RESULT(&r); }
RESULT RESULT::operator += (const RESULT & r) const { return RESULT (value + r.value); }
/** result_next : 'result -> object? <doc> Return the next row if available. A row is represented as an object, which fields have been converted to the corresponding Neko value (int, float or string). For Date and DateTime you can specify your own conversion function using [result_set_conv_date]. By default they're returned as plain strings. Additionally, the TINYINT(1) will be converted to either true or false if equal to 0. </doc> **/ static value result_next( value o ) { result *r; unsigned long *lengths = NULL; MYSQL_ROW row; val_check_kind(o,k_result); r = RESULT(o); row = mysql_fetch_row(r->r); if( row == NULL ) return val_null; { int i; value cur = alloc_object(NULL); r->current = row; for(i=0;i<r->nfields;i++) if( row[i] != NULL ) { value v; switch( r->fields_convs[i] ) { case CONV_INT: v = alloc_int(atoi(row[i])); break; case CONV_STRING: v = alloc_string(row[i]); if( r->conv_string != NULL ) v = val_call1(r->conv_string,v); break; case CONV_BOOL: v = alloc_bool( *row[i] != '0' ); break; case CONV_FLOAT: v = alloc_float(atof(row[i])); break; case CONV_BINARY: if( lengths == NULL ) { lengths = mysql_fetch_lengths(r->r); if( lengths == NULL ) val_throw(alloc_string("mysql_fetch_lengths")); } v = copy_string(row[i],lengths[i]); if( r->conv_bytes != NULL ) v = val_call1(r->conv_bytes,v); break; case CONV_DATE: if( r->conv_date == NULL ) v = alloc_string(row[i]); else { struct tm t; sscanf(row[i],"%4d-%2d-%2d",&t.tm_year,&t.tm_mon,&t.tm_mday); t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; t.tm_isdst = -1; t.tm_year -= 1900; t.tm_mon--; v = val_call1(r->conv_date,alloc_int32((int)mktime(&t))); } break; case CONV_DATETIME: if( r->conv_date == NULL ) v = alloc_string(row[i]); else { struct tm t; sscanf(row[i],"%4d-%2d-%2d %2d:%2d:%2d",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec); t.tm_isdst = -1; t.tm_year -= 1900; t.tm_mon--; v = val_call1(r->conv_date,alloc_int32((int)mktime(&t))); } break; default: v = val_null; break; } alloc_field(cur,r->fields_ids[i],v); } return cur; } }
nsresult writeoutto(const char* i_pURL, char** o_Result, PRInt32 urlFactory = URL_FACTORY_DEFAULT) { if (!o_Result || !i_pURL) return NS_ERROR_FAILURE; *o_Result = 0; nsCOMPtr<nsIURI> pURL; nsresult result = NS_OK; switch (urlFactory) { case URL_FACTORY_STDURL: { nsIURI* url; result = CallCreateInstance(kStdURLCID, &url); if (NS_FAILED(result)) { printf("CreateInstance failed\n"); return NS_ERROR_FAILURE; } pURL = url; pURL->SetSpec(nsDependentCString(i_pURL)); break; } case URL_FACTORY_DEFAULT: { nsCOMPtr<nsIIOService> pService = do_GetService(kIOServiceCID, &result); if (NS_FAILED(result)) { printf("Service failed!\n"); return NS_ERROR_FAILURE; } result = pService->NewURI(nsDependentCString(i_pURL), nullptr, nullptr, getter_AddRefs(pURL)); } } nsCString output; if (NS_SUCCEEDED(result)) { nsCOMPtr<nsIURL> tURL = do_QueryInterface(pURL); nsCAutoString temp; PRInt32 port; nsresult rv; #define RESULT() NS_SUCCEEDED(rv) ? temp.get() : "" rv = tURL->GetScheme(temp); output += RESULT(); output += ','; rv = tURL->GetUsername(temp); output += RESULT(); output += ','; rv = tURL->GetPassword(temp); output += RESULT(); output += ','; rv = tURL->GetHost(temp); output += RESULT(); output += ','; rv = tURL->GetPort(&port); char portbuffer[40]; PR_snprintf(portbuffer, sizeof(portbuffer), "%d", port); output.Append(portbuffer); output += ','; rv = tURL->GetDirectory(temp); output += RESULT(); output += ','; rv = tURL->GetFileBaseName(temp); output += RESULT(); output += ','; rv = tURL->GetFileExtension(temp); output += RESULT(); output += ','; // removed with https://bugzilla.mozilla.org/show_bug.cgi?id=665706 // rv = tURL->GetParam(temp); // output += RESULT(); output += ','; rv = tURL->GetQuery(temp); output += RESULT(); output += ','; rv = tURL->GetRef(temp); output += RESULT(); output += ','; rv = tURL->GetSpec(temp); output += RESULT(); *o_Result = ToNewCString(output); } else { output = "Can not create URL"; *o_Result = ToNewCString(output); } return NS_OK; }
/** result_get_length : 'result -> int <doc>Return the number of rows returned or affected</doc> **/ static value result_get_length( value o ) { if( val_is_int(o) ) return o; val_check_kind(o,k_result); return alloc_int( (int)mysql_num_rows(RESULT(o)->r) ); }
/** result_get_nfields : 'result -> int <doc>Return the number of fields in a result row</doc> **/ static value result_get_nfields( value o ) { val_check_kind(o,k_result); return alloc_int(RESULT(o)->nfields); }
static VALUE Log_log_1px_mx_e(VALUE self, VALUE x) { int ret; gsl_sf_result r; ret = gsl_sf_log_1plusx_mx_e(NUM2DBL(x), &r); return RESULT(&r); }
RESULT TARGETSEARCH::downbound () { return RESULT (INT_MIN); }
RESULT TARGETSEARCH::upbound () { return RESULT (INT_MAX); }
STDAPI VariantChangeType( VARIANTARG FAR* pvargDest, VARIANTARG FAR* pvargSrc, unsigned short wFlags, VARTYPE vt) { VARIANT varTmp; HRESULT hresult; VARTYPE vtSrc; if (pvargDest == NULL || pvargSrc == NULL) return(E_INVALIDARG); vtSrc = V_VT(pvargSrc); // get src vartype hresult = NOERROR; // assume success // NOTE: all code after this point must go to LError0 upon Error. // should have validated the destination type at this point (to ensure // that the below optimized switch statement will work properly). switch ( VTSW(vtSrc, vt) ) { case VTSW(VT_BOOL, VT_BOOL): case VTSW(VT_I2, VT_I2): case VTSW(VT_I4, VT_I4): case VTSW(VT_INT, VT_INT): case VTSW(VT_I8, VT_I8): case VTSW(VT_R4, VT_R4): case VTSW(VT_R8, VT_R8): case VTSW(VT_CY, VT_CY): case VTSW(VT_DECIMAL, VT_DECIMAL): case VTSW(VT_I1, VT_I1): case VTSW(VT_UI1, VT_UI1): case VTSW(VT_UI2, VT_UI2): case VTSW(VT_UI4, VT_UI4): case VTSW(VT_UINT, VT_UINT): case VTSW(VT_UI8, VT_UI8): varTmp = *pvargSrc; break; case VTSW(VT_EMPTY, VT_BSTR): hresult = ErrSysAllocString(OASTR(""), &V_BSTR(&varTmp)); break; case VTSW(VT_BOOL, VT_BSTR): //fall through to return "0" or "-1" case VTSW(VT_I2, VT_BSTR): hresult = VarBstrFromI2(V_I2(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_I4, VT_BSTR): case VTSW(VT_INT, VT_BSTR): hresult = VarBstrFromI4(V_I4(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_I8, VT_BSTR): hresult = VarBstrFromI8(V_I8(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_R4, VT_BSTR): hresult = VarBstrFromR4(V_R4(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_R8, VT_BSTR): hresult = VarBstrFromR8(V_R8(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_CY, VT_BSTR): hresult = VarBstrFromCy(V_CY(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_DECIMAL, VT_BSTR): hresult = VarBstrFromDec(&pvargSrc->n1.decVal, LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_I1, VT_BSTR): hresult = VarBstrFromI1(V_I1(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_UI1, VT_BSTR): hresult = VarBstrFromUI1(V_UI1(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_UI2, VT_BSTR): hresult = VarBstrFromUI2(V_UI2(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_UI4, VT_BSTR): case VTSW(VT_UINT, VT_BSTR): hresult = VarBstrFromUI4(V_UI4(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_UI8, VT_BSTR): hresult = VarBstrFromUI8(V_UI8(pvargSrc), LOCALE_USER_DEFAULT, 0, &V_BSTR(&varTmp)); break; case VTSW(VT_BSTR, VT_BSTR): hresult = ErrSysAllocString(V_BSTR(pvargSrc), &V_BSTR(&varTmp)); break; case VTSW(VT_DATE, VT_BSTR): _ASSERTE(false); hresult = RESULT(DISP_E_TYPEMISMATCH); break; default: if (vtSrc >= VT_VARIANT) { IfFailGo(IsLegalVartype(vtSrc), LError0); } // everybody else gets a type mis-match error _ASSERTE(false); hresult = RESULT(DISP_E_TYPEMISMATCH); break; } if (FAILED(hresult)) { goto LError0; } // now set the tag in temp variant. Errors after this point have to // goto LError1 to potentially clear this variant. V_VT(&varTmp) = vt; // now that we have succeeded, we can go ahead and destroy our // destination variant. if (V_VT(pvargDest) >= VT_BSTR) { IfFailGo(VariantClear(pvargDest), LError1); } // copy in the variant we just created memcpy(pvargDest, &varTmp, sizeof(VARIANT)); return NOERROR; LError1:; VariantClear(&varTmp); // fall through LError0:; return hresult; }
static void free_result( value o ) { result *r = RESULT(o); mysql_free_result(r->r); }
STDAPI VarCyFromR8(DOUBLE dblInput, CY * pcyOut) { BOOL fNegative = FALSE; double dblHi, dblLo; float flt; double dblDif; // test for overflow first // [Note: We are counting on the compiler rounding the following numbers // correctly (by IEEE rules to the nearest R8). The magnitude of these // numbers are rounded up and, thus, are always outside the legal range // for currency. if (dblInput >= 922337203685477.58 || dblInput <= -922337203685477.58) return RESULT(DISP_E_OVERFLOW); // if negative, set flag and make positive if (dblInput < 0.0) { fNegative = TRUE; dblInput = -dblInput; } // In order to maintain the necessary precision when multiplying // by 10000 (i.e., going from 53-bit to 64-bit), split the // input value into two different doubles and perform calcs using // them: // // dblHi = has low bits 0 // dblLo = has high bits 0 // // split input into two parts // Note: compiler doesn't do the right thing with this: // "dblHi = (double) (float) dblInput" flt = (float) dblInput; dblHi = (double) flt; // input rounded to 24-bit precision dblLo = dblInput - dblHi; // diff between 24- and 53-bit input value // bias for currency dblHi = dblHi * 10000; dblLo = dblLo * 10000; // calculate cy.Hi pcyOut->u.Hi = (long) ((dblLo + dblHi) / C2TO32TH); // calculate cy.Lo dblHi -= (((double) pcyOut->u.Hi) * C2TO32TH); pcyOut->u.Lo = (unsigned long) (dblLo + dblHi); // round as necessary dblHi -= (double)(pcyOut->u.Lo) + 0.5; dblDif = dblLo + dblHi; if ( (dblDif > 0) || ((dblDif == 0) && (pcyOut->u.Lo & 1)) ) { pcyOut->u.Lo++; if (pcyOut->u.Lo == 0) pcyOut->u.Hi++; } // negate the result if input was negative if (fNegative) { pcyOut->u.Hi = ~pcyOut->u.Hi; if ((pcyOut->u.Lo = (unsigned long)(-(long)pcyOut->u.Lo)) == 0) pcyOut->u.Hi++; } return NOERROR; }
static VALUE Elementary_multiply_e(VALUE self, VALUE x, VALUE y) { int ret; gsl_sf_result r; ret = gsl_sf_multiply_e(NUM2DBL(x), NUM2DBL(y), &r); return RESULT(&r); }
static VALUE Airy_zero_Bi_deriv_e(VALUE self, VALUE s) { int ret; gsl_sf_result r; ret = gsl_sf_airy_zero_Bi_deriv_e(NUM2UINT(s), &r); return RESULT(&r); }
static RESULT make( mbox_t mbox ) { return RESULT( std::move( mbox ) ); }
int main (int argc, char **argv) { unsigned long i, k; struct timespec runtime; timing_t start, end; bool detailed = false; json_ctx_t json_ctx; if (argc == 2 && !strcmp (argv[1], "-d")) detailed = true; bench_start (); memset (&runtime, 0, sizeof (runtime)); unsigned long iters, res; #ifdef BENCH_INIT BENCH_INIT (); #endif TIMING_INIT (res); iters = 1000 * res; json_init (&json_ctx, 2, stdout); /* Begin function. */ json_attr_object_begin (&json_ctx, FUNCNAME); for (int v = 0; v < NUM_VARIANTS; v++) { /* Run for approximately DURATION seconds. */ clock_gettime (CLOCK_MONOTONIC_RAW, &runtime); runtime.tv_sec += DURATION; double d_total_i = 0; timing_t total = 0, max = 0, min = 0x7fffffffffffffff; int64_t c = 0; while (1) { for (i = 0; i < NUM_SAMPLES (v); i++) { uint64_t cur; TIMING_NOW (start); for (k = 0; k < iters; k++) BENCH_FUNC (v, i); TIMING_NOW (end); TIMING_DIFF (cur, start, end); if (cur > max) max = cur; if (cur < min) min = cur; TIMING_ACCUM (total, cur); /* Accumulate timings for the value. In the end we will divide by the total iterations. */ RESULT_ACCUM (cur, v, i, c * iters, (c + 1) * iters); d_total_i += iters; } c++; struct timespec curtime; memset (&curtime, 0, sizeof (curtime)); clock_gettime (CLOCK_MONOTONIC_RAW, &curtime); if (TIMESPEC_AFTER (curtime, runtime)) goto done; } double d_total_s; double d_iters; done: d_total_s = total; d_iters = iters; /* Begin variant. */ json_attr_object_begin (&json_ctx, VARIANT (v)); json_attr_double (&json_ctx, "duration", d_total_s); json_attr_double (&json_ctx, "iterations", d_total_i); json_attr_double (&json_ctx, "max", max / d_iters); json_attr_double (&json_ctx, "min", min / d_iters); json_attr_double (&json_ctx, "mean", d_total_s / d_total_i); if (detailed) { json_array_begin (&json_ctx, "timings"); for (int i = 0; i < NUM_SAMPLES (v); i++) json_element_double (&json_ctx, RESULT (v, i)); json_array_end (&json_ctx); } /* End variant. */ json_attr_object_end (&json_ctx); } /* End function. */ json_attr_object_end (&json_ctx); return 0; }
static int next_def_nolb25(unicode_lb_info_t i, uint8_t uclass, /* Flag -- recursively invoked after discarding LB25 */ int nolb25) { /* Retrieve the previous unicode character's linebreak class. */ uint8_t prevclass_min1=i->prevclass_min1; uint8_t prevclass=i->prevclass; uint8_t prevclass_nsp=i->prevclass_nsp; #define RESTORE (i->prevclass_min1=prevclass_min1, \ i->prevclass=prevclass, \ i->prevclass_nsp=prevclass_nsp) \ /* Save this unicode char's linebreak class, for the next goaround */ i->prevclass_min1=i->prevclass; i->prevclass=uclass; if (uclass != UNICODE_LB_SP) i->prevclass_nsp=uclass; if (uclass == UNICODE_LB_NU) i->next_handler=next_lb25_seennu; /* LB25 */ if (prevclass == UNICODE_LB_SOT) { if (uclass == UNICODE_LB_CM) /* LB9 */ i->prevclass=i->prevclass_nsp=uclass=UNICODE_LB_AL; return RESULT(UNICODE_LB_NONE); /* LB2 */ } if (prevclass == UNICODE_LB_CR && uclass == UNICODE_LB_LF) return RESULT(UNICODE_LB_NONE); /* LB5 */ switch (prevclass) { case UNICODE_LB_BK: case UNICODE_LB_CR: case UNICODE_LB_LF: case UNICODE_LB_NL: if (uclass == UNICODE_LB_CM) { i->prevclass=i->prevclass_nsp=uclass=UNICODE_LB_AL; /* LB9 */ } return RESULT(UNICODE_LB_MANDATORY); /* LB4, LB5 */ case UNICODE_LB_SP: case UNICODE_LB_ZW: if (uclass == UNICODE_LB_CM) i->prevclass=i->prevclass_nsp=uclass=UNICODE_LB_AL; /* LB10 */ break; default: break; } switch (uclass) { /* LB6: */ case UNICODE_LB_BK: case UNICODE_LB_CR: case UNICODE_LB_LF: case UNICODE_LB_NL: /* LB7: */ case UNICODE_LB_SP: case UNICODE_LB_ZW: return RESULT(UNICODE_LB_NONE); default: break; } if (prevclass_nsp == UNICODE_LB_ZW) return RESULT(UNICODE_LB_ALLOWED); /* LB8 */ if (uclass == UNICODE_LB_CM) { RESTORE; return RESULT(UNICODE_LB_NONE); /* LB9 */ } if (prevclass == UNICODE_LB_WJ || uclass == UNICODE_LB_WJ) return RESULT(UNICODE_LB_NONE); /* LB11 */ if (prevclass == UNICODE_LB_GL) return RESULT(UNICODE_LB_NONE); /* LB12 */ if (uclass == UNICODE_LB_GL && prevclass != UNICODE_LB_SP && prevclass != UNICODE_LB_BA && prevclass != UNICODE_LB_HY) return RESULT(UNICODE_LB_NONE); /* LB12a */ switch (uclass) { case UNICODE_LB_SY: if (i->opts & UNICODE_LB_OPT_SYBREAK) { if (prevclass == UNICODE_LB_SP) return RESULT(UNICODE_LB_ALLOWED); } case UNICODE_LB_CL: case UNICODE_LB_CP: case UNICODE_LB_EX: case UNICODE_LB_IS: return RESULT(UNICODE_LB_NONE); /* LB13 */ default: break; } if ((i->opts & UNICODE_LB_OPT_SYBREAK) && prevclass == UNICODE_LB_SY) switch (uclass) { case UNICODE_LB_EX: case UNICODE_LB_AL: case UNICODE_LB_ID: return RESULT(UNICODE_LB_NONE); } if (prevclass_nsp == UNICODE_LB_OP) return RESULT(UNICODE_LB_NONE); /* LB14 */ if (prevclass_nsp == UNICODE_LB_QU && uclass == UNICODE_LB_OP) return RESULT(UNICODE_LB_NONE); /* LB15 */ if ((prevclass_nsp == UNICODE_LB_CL || prevclass_nsp == UNICODE_LB_CP) && uclass == UNICODE_LB_NS) return RESULT(UNICODE_LB_NONE); /* LB16 */ if (prevclass_nsp == UNICODE_LB_B2 && uclass == UNICODE_LB_B2) return RESULT(UNICODE_LB_NONE); /* LB17 */ if (prevclass == UNICODE_LB_SP) return RESULT(UNICODE_LB_ALLOWED); /* LB18 */ if (uclass == UNICODE_LB_QU || prevclass == UNICODE_LB_QU) return RESULT(UNICODE_LB_NONE); /* LB19 */ if (uclass == UNICODE_LB_CB || prevclass == UNICODE_LB_CB) return RESULT(UNICODE_LB_ALLOWED); /* LB20 */ /* LB21: */ switch (uclass) { case UNICODE_LB_BA: case UNICODE_LB_HY: case UNICODE_LB_NS: return RESULT(UNICODE_LB_NONE); default: break; } if (prevclass == UNICODE_LB_BB) return RESULT(UNICODE_LB_NONE); /* LB21a: */ if (prevclass_min1 == UNICODE_LB_HL && (prevclass == UNICODE_LB_HY || prevclass == UNICODE_LB_BA)) return RESULT(UNICODE_LB_NONE); /* LB21b: */ if (prevclass == UNICODE_LB_SY && uclass == UNICODE_LB_HL) return RESULT(UNICODE_LB_NONE); if (uclass == UNICODE_LB_IN) switch (prevclass) { case UNICODE_LB_AL: case UNICODE_LB_EX: case UNICODE_LB_HL: case UNICODE_LB_ID: case UNICODE_LB_IN: case UNICODE_LB_NU: return RESULT(UNICODE_LB_NONE); /* LB22 */ default: break; } if (prevclass == UNICODE_LB_ID && uclass == UNICODE_LB_PO) return RESULT(UNICODE_LB_NONE); /* LB23 */ if (prevclass == UNICODE_LB_AL && uclass == UNICODE_LB_NU) return RESULT(UNICODE_LB_NONE); /* LB23 */ if (prevclass == UNICODE_LB_HL && uclass == UNICODE_LB_NU) return RESULT(UNICODE_LB_NONE); /* LB23 */ if (prevclass == UNICODE_LB_NU && uclass == UNICODE_LB_AL) return RESULT(UNICODE_LB_NONE); /* LB23 */ if (prevclass == UNICODE_LB_NU && uclass == UNICODE_LB_HL) return RESULT(UNICODE_LB_NONE); /* LB23 */ if (prevclass == UNICODE_LB_PR && uclass == UNICODE_LB_ID) return RESULT(UNICODE_LB_NONE); /* LB24 */ if (prevclass == UNICODE_LB_PR && uclass == UNICODE_LB_AL) return RESULT(UNICODE_LB_NONE); /* LB24 */ if (prevclass == UNICODE_LB_PR && uclass == UNICODE_LB_HL) return RESULT(UNICODE_LB_NONE); /* LB24 */ if (prevclass == UNICODE_LB_PO && uclass == UNICODE_LB_AL) return RESULT(UNICODE_LB_NONE); /* LB24 */ if (prevclass == UNICODE_LB_PO && uclass == UNICODE_LB_HL) return RESULT(UNICODE_LB_NONE); /* LB24 */ if ((i->opts & UNICODE_LB_OPT_PRBREAK) && uclass == UNICODE_LB_PR) switch (prevclass) { case UNICODE_LB_PR: case UNICODE_LB_AL: case UNICODE_LB_ID: return RESULT(UNICODE_LB_NONE); } if (!nolb25 && (prevclass == UNICODE_LB_PR || prevclass == UNICODE_LB_PO)) { if (uclass == UNICODE_LB_NU) return RESULT(UNICODE_LB_NONE); /* LB25 */ if (uclass == UNICODE_LB_OP || uclass == UNICODE_LB_HY) { RESTORE; i->savedclass=uclass; i->savedcmcnt=0; i->next_handler=next_lb25_seenophy; i->end_handler=end_lb25_seenophy; return 0; } } if ((prevclass == UNICODE_LB_OP || prevclass == UNICODE_LB_HY) && uclass == UNICODE_LB_NU) return RESULT(UNICODE_LB_NONE); /* LB25 */ /*****/ if (prevclass == UNICODE_LB_JL) switch (uclass) { case UNICODE_LB_JL: case UNICODE_LB_JV: case UNICODE_LB_H2: case UNICODE_LB_H3: return RESULT(UNICODE_LB_NONE); /* LB26 */ default: break; } if ((prevclass == UNICODE_LB_JV || prevclass == UNICODE_LB_H2) && (uclass == UNICODE_LB_JV || uclass == UNICODE_LB_JT)) return RESULT(UNICODE_LB_NONE); /* LB26 */ if ((prevclass == UNICODE_LB_JT || prevclass == UNICODE_LB_H3) && uclass == UNICODE_LB_JT) return RESULT(UNICODE_LB_NONE); /* LB26 */ switch (prevclass) { case UNICODE_LB_JL: case UNICODE_LB_JV: case UNICODE_LB_JT: case UNICODE_LB_H2: case UNICODE_LB_H3: if (uclass == UNICODE_LB_IN || uclass == UNICODE_LB_PO) return RESULT(UNICODE_LB_NONE); /* LB27 */ default: break; } switch (uclass) { case UNICODE_LB_JL: case UNICODE_LB_JV: case UNICODE_LB_JT: case UNICODE_LB_H2: case UNICODE_LB_H3: if (prevclass == UNICODE_LB_PR) return RESULT(UNICODE_LB_NONE); /* LB27 */ default: break; } if ((prevclass == UNICODE_LB_AL || prevclass == UNICODE_LB_HL) && (uclass == UNICODE_LB_AL || uclass == UNICODE_LB_HL)) return RESULT(UNICODE_LB_NONE); /* LB28 */ if (prevclass == UNICODE_LB_IS && (uclass == UNICODE_LB_AL || uclass == UNICODE_LB_HL)) return RESULT(UNICODE_LB_NONE); /* LB29 */ if ((prevclass == UNICODE_LB_AL || prevclass == UNICODE_LB_HL || prevclass == UNICODE_LB_NU) && uclass == UNICODE_LB_OP) return RESULT(UNICODE_LB_NONE); /* LB30 */ if ((uclass == UNICODE_LB_AL || uclass == UNICODE_LB_HL || uclass == UNICODE_LB_NU) && prevclass == UNICODE_LB_CP) return RESULT(UNICODE_LB_NONE); /* LB30 */ if (uclass == UNICODE_LB_RI && prevclass == UNICODE_LB_RI) return RESULT(UNICODE_LB_NONE); /* LB30a */ return RESULT(UNICODE_LB_ALLOWED); /* LB31 */ }