int main(void) { setlocale(LC_ALL,""); int year1, year2, year3; wchar_t name1[18], name2[18], name3[18]; int d1=0, d2=0, d3=0, f1=0, f2=0, f3=0; /* Введение фактических данных*/ wprintf(L"1. Введите: год, научный руководитель, диаметр антенны(м), рабочая частота(МГц) > "); wscanf(L"%d %s %d %d",&year1, name1, &d1, &f1); wprintf(L"2. Введите: год, научный руководитель, диаметр антенны(м), рабочая частота(МГц) > "); wscanf(L"%d %s %d %d",&year2, name2, &d2, &f2); wprintf(L"3. Введите: год, научный руководитель, диаметр антенны(м), рабочая частота(МГц) > "); wscanf(L"%d %s %d %d",&year3, name3, &d3, &f3); /* Вывод таблицы */ /* вывод заголовков */ wprintf(L"--------------------------------------------\n"); wprintf(L"|Проекты поиска внеземных сигналов |\n"); wprintf(L"|------------------------------------------|\n"); wprintf(L"| Год | Научный | Диаметр | Рабочая |\n"); wprintf(L"| | руководитель | антены | частота |\n"); wprintf(L"|-------|--------------|---------|---------|\n"); /* вывод строк фактических данных */ wprintf(L"| %5d | %-12s | %7d | %7d |\n", year1, name1, d1, f1); wprintf(L"| %5d | %-12s | %7d | %7d |\n", year2, name2, d2, f2); wprintf(L"| %5d | %-12s | %7d | %7d |\n", year3, name3, d3, f3); /* вывод примечаний */ wprintf(L"|------------------------------------------|\n"); wprintf(L"| Примечание: наблюдались объекты от |\n"); wprintf(L"| 2 звезд до нескольких галактик |\n"); wprintf(L"--------------------------------------------\n"); return 0; }
int _tmain(int argc, _TCHAR* argv[]) { DWORD lastError=ERROR_SUCCESS; LPWSTR filePath=NULL; HANDLE logFileHandle=NULL; HANDLE openFileHandle= NULL; BOOL copyingBool=TRUE; DWORD counter=0; DWORD readed = 0; DWORD lengthToRead=0; LPWSTR buffer = NULL; LARGE_INTEGER lengthOfFile = {0}; logFileHandle = CreateFile( LOG_FILE_NAME, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if((logFileHandle == INVALID_HANDLE_VALUE) || (logFileHandle == NULL)) goto error; _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); _CrtSetReportFile(_CRT_WARN, logFileHandle); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); _CrtSetReportFile(_CRT_ERROR, logFileHandle); _RPTFW0(_CRT_WARN, L"Starting debug logs.\n"); Init(); counter=0; wprintf(L"Choose existing no empty directory: \n"); wscanf(L"%s",directoryPath); while((counter<2)&&!OpenDir()) { wprintf(L"Choose existing no empty directory (for example C:\\mydir): \n"); wscanf(L"%s",directoryPath); counter++; } if(!OpenDir()) { _RPTFW0(_CRT_WARN, L"No path selected. \n"); wprintf(L"No path selected. \n"); lastError=ERROR_INVALID_COMMAND_LINE; goto final; }
int _CRTAPI1 Zwscanf (const wchar_t* Arg1, DWORD64ARGS) { int RetVal; SHORT sTimerHandle; ULONG ulElapsedTime; if (fInitDone == FALSE) { ApfInitDll(); } TimerOpen(&sTimerHandle, MICROSECONDS); TimerInit(sTimerHandle); // // Call the api // RetVal = wscanf(Arg1, ARGS64); // // Get the elapsed time // ulElapsedTime = TimerRead(sTimerHandle); ApfRecordInfo(I_wscanf, ulElapsedTime - ApfData[I_CALIBRATE].ulFirstTime); TimerClose(sTimerHandle); return(RetVal); }
Value get_char() { Value value; //value.character = getwchar(); wscanf(L"%lc",&(value.character)); value.integer = value.character & 0xFFFF; return value; }
int main() { wchar_t texto[20]; setlocale(LC_ALL, "pt_BR.UTF-8"); wscanf(L"%ls", texto); filtraTexto(texto); wprintf(L"%ls\n", texto); return 0; }
int __cdecl wmain (int argc, WCHAR* args[]) { WCHAR wszRegPath[MAX_LEN] ; int iTimeout=0; BOOL bEnd = FALSE; while(!bEnd) { wprintf(L"Enter registry key path (\"quit\" to quit): "); wscanf(L"%s", wszRegPath, MAX_LEN); if(!_wcsicmp(wszRegPath, L"quit")) { bEnd=TRUE; continue; } wprintf(L"Enter timeout for enumeration: "); wscanf(L"%d", &iTimeout); if(iTimeout==0) { wprintf(L"Invalid timeout specified...\n"); bEnd=TRUE; } else { // // Enumerate // if ( RegEnum(wszRegPath, iTimeout) == FALSE ) { DisplayError(wszRegPath, REG_DWORD, iTimeout, TRUE); } } } return 0; }
void CWE252_Unchecked_Return_Value__wchar_t_scanf_07_bad() { if(staticFive==5) { { /* By initializing dataBuffer, we ensure this will not be the * CWE 690 (Unchecked Return Value To NULL Pointer) flaw for fgetws() and other variants */ wchar_t dataBuffer[100] = L""; wchar_t * data = dataBuffer; /* FLAW: Do not check the return value */ wscanf(L"%99s\0", data); } } }
int main(int argc, char* argv[]) { wchar_t command[3] = { L'\0', L'\0', L'\0' }; while (command[0] != L'Y' && command[0] != L'y') { wprintf(L"*** CMake Tutorial Program Example:\n"); wprintf(L"Enter the desired example code number or ? for a code list: "); //wscanf_s(L"%s", &command[0], 3); wscanf(L"%s", &command[0]); wprintf(L"\n\n"); int example_id = -1; try { //example_id = std::stoi(command); example_id = 0; } catch (...) { example_id = 0; } if (!ExecuteCommand(example_id)) { if (command[0] == L'0') { command[0] = L'Y'; continue; } if (command[0] != L'?') { wprintf(L"The command %s is invalid!\n\n", command); command[0] = L'\0'; continue; } CommandList(); continue; } wprintf(L"\n\n"); } return 0; }
/* good2() reverses the bodies in the if statement */ static void good2() { if(staticFive==5) { { /* By initializing dataBuffer, we ensure this will not be the * CWE 690 (Unchecked Return Value To NULL Pointer) flaw for fgetws() and other variants */ wchar_t dataBuffer[100] = L""; wchar_t * data = dataBuffer; /* FIX: check the return value */ if (wscanf(L"%99s\0", data) == EOF) { printLine("wscanf failed!"); } } } }
static void wide (const char *path) { FILE *old_stdin = stdin; stdin = xfopen (path, "r"); TEST_COMPARE (getwchar (), L'a'); TEST_COMPARE (getwchar_unlocked (), L'b'); wchar_t ch = 1; TEST_COMPARE (wscanf (L"%lc", &ch), 1); TEST_COMPARE (ch, L'c'); TEST_COMPARE (call_vwscanf (L"%lc", &ch), 1); TEST_COMPARE (ch, L'd'); fclose (stdin); stdin = old_stdin; }
/* good1() uses if(staticFive!=5) instead of if(staticFive==5) */ static void good1() { if(staticFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { { /* By initializing dataBuffer, we ensure this will not be the * CWE 690 (Unchecked Return Value To NULL Pointer) flaw for fgetws() and other variants */ wchar_t dataBuffer[100] = L""; wchar_t * data = dataBuffer; /* FIX: check the return value */ if (wscanf(L"%99s\0", data) == EOF) { printLine("wscanf failed!"); } } } }
int main() { struct record { wchar_t name[64]; int age; _Bool male, smoking, discount; } this; int results; wprintf( L"Last name: " ); results = wscanf( L"%63l[^\n]", this.name ); if ( results < 1 ) wcscpy( this.name, L"[Name not available]" ); // or: // wcscpy_s( this.name, sizeof(this.name)/sizeof(wchar_t), // L"[Name not available]" ); wprintf( L"%ls\n", this.name ); return 0; }
int main() { struct wierzcholek *korzen=NULL; wchar_t nastepne_slowo[100]; setlocale(LC_CTYPE,""); wchar_t slowo1[100]; while(wscanf(L"%s",slowo1)==1){ wcscpy(nastepne_slowo,slowo1); korzen = wstaw_wierzcholek(korzen,lowercase(nastepne_slowo)); } inorder_print(korzen); return EXIT_SUCCESS; }
//--------------------------------------------------------------------------------------------- int x86FixupScanfAvoidKill(void) { x86FixupAvoidKill fuzz; wchar_t pimagepath[MAX_PATH] = {0}; wprintf(L"fill path:"); wscanf(L"%s",pimagepath); if(!fuzz.x86FixupFullTarget(pimagepath)) { return EXIT_FAILURE; } else { if(!fuzz.x86FixupFuzzAssembly()) { return EXIT_FAILURE; } else { fuzz.x86FixupGenFuzzResult(); fuzz.logFuzzme("fuzz ok!"); return EXIT_SUCCESS; } } }
int main(int argc, char* argv[]) { int res; unsigned char buf[65]; wchar_t wstr[MAX_STR]; hid_device *handle; int i; int j = 0; short accX[DATA_PTS]; short accY[DATA_PTS]; short accZ[DATA_PTS]; // Initialize the hidapi library res = hid_init(); // Open the device using the VID, PID, // and optionally the Serial number. handle = hid_open(0x4d8, 0x3f, NULL); // Read the Manufacturer String res = hid_get_manufacturer_string(handle, wstr, MAX_STR); wprintf(L"Manufacturer String: %s\n", wstr); // Read the Product String res = hid_get_product_string(handle, wstr, MAX_STR); wprintf(L"Product String: %s\n", wstr); // Read the Serial Number String res = hid_get_serial_number_string(handle, wstr, MAX_STR); wprintf(L"Serial Number String: (%d) %s\n", wstr[0], wstr); // Read Indexed String 1 res = hid_get_indexed_string(handle, 1, wstr, MAX_STR); wprintf(L"Indexed String 1: %s\n", wstr); char message[MAX_MSG]; wprintf(L"Input message:\n"); wscanf(L"%[^\n]s", message); int row=0; wprintf(L"Input row:\n", wstr); wscanf(L"%d", &row); // Toggle LED (cmd 0x80). The first byte is the report number (0x0). buf[0] = 0x0; buf[1] = 0x80; buf[3] = row; for (i = 0; i < MAX_MSG; i++) buf[i+5] = message[i]; res = hid_write(handle, buf, 65); // Request state (cmd 0x81). The first byte is the report number (0x0). buf[0] = 0x0; buf[1] = 0x81; res = hid_write(handle, buf, 65); // Read requested state //res = hid_read(handle, buf, 65); // Print out the returned buffer. //for (i = 0; i < 7; i++) // printf("buf[%d]: %d\n", i, buf[i]); // Read requested state while (j < DATA_PTS) { buf[0] = 0x0; buf[1] = 0x81; res = hid_write(handle, buf, 65); res = hid_read(handle, buf, 65); if (buf[0] == 0x81) { accX[j] = ((buf[1] << 8) | (buf[2])); accY[j] = ((buf[3] << 8) | (buf[4])); accZ[j] = ((buf[5] << 8) | (buf[6])); j++; } } //Save to a file wprintf(L"Saving to file\n"); FILE *ofp; ofp = fopen("accels.txt", "w"); for (i=0; i<DATA_PTS; i++) { wprintf(L"X: %d Y: %d Z: %d\r\n",accX[i],accY[i],accZ[i]); fwprintf(ofp,L"%d, %d, %d\r\n",accX[i],accY[i],accZ[i]); } fclose(ofp); // Finalize the hidapi library res = hid_exit(); for (i = 0; i<65; i++) buf[i] = 0; return 0; }
int main() { mbstate_t mb = {0}; size_t s = 0; tm tm = {0}; wint_t w = 0; ::FILE* fp = 0; __darwin_va_list va; char* ns = 0; wchar_t* ws = 0; static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), ""); static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), ""); static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), ""); static_assert((std::is_same<decltype(swscanf(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(vfwprintf(fp, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), ""); static_assert((std::is_same<decltype(wprintf(L"")), int>::value), ""); static_assert((std::is_same<decltype(wscanf(L"")), int>::value), ""); static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), ""); static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), ""); static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(getwchar()), wint_t>::value), ""); static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), ""); static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), ""); static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), ""); static_assert((std::is_same<decltype(wcstold(L"", (wchar_t**)0)), long double>::value), ""); static_assert((std::is_same<decltype(wcstol(L"", (wchar_t**)0, 0)), long>::value), ""); static_assert((std::is_same<decltype(wcstoll(L"", (wchar_t**)0, 0)), long long>::value), ""); static_assert((std::is_same<decltype(wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), ""); static_assert((std::is_same<decltype(wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), ""); static_assert((std::is_same<decltype(wcscpy(ws, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsncpy(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscat(ws, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsncat(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscmp(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), ""); static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemmove(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemset(ws, L' ', s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsftime(ws, s, L"", &tm)), size_t>::value), ""); static_assert((std::is_same<decltype(btowc(0)), wint_t>::value), ""); static_assert((std::is_same<decltype(wctob(w)), int>::value), ""); static_assert((std::is_same<decltype(mbsinit(&mb)), int>::value), ""); static_assert((std::is_same<decltype(mbrlen("", s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(mbrtowc(ws, "", s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), ""); }
static void menu_0_1(ldr_config *conf) { wchar_t auth[MAX_PATH]; wchar_t *dp_type; char ch; do { cls_console(); if (conf->options & OP_EPS_TMO) { _snwprintf( auth, sizeof_w(auth), L"%d seconds", conf->timeout); } else { wcscpy(auth, L"disabled"); } if (conf->logon_type & LT_DSP_PASS) { dp_type = L"display \"*\""; } else { dp_type = L"disabled"; } wprintf( L"1 - On/Off \"enter password\" message (%s)\n" L"2 - Change display password type (%s)\n" L"3 - Change password prompt text (%S)\n" L"4 - Enable embedded keyfile (%s)\n" L"5 - Change authentication timeout (%s)\n" L"6 - Cancel timeout if any key pressed (%s)\n" L"7 - Return to main menu\n\n", on_off(conf->logon_type & LT_MESSAGE), dp_type, conf->eps_msg, conf->logon_type & LT_EMBED_KEY ? L"enabled":L"disabled", auth, on_off(conf->options & OP_TMO_STOP)); if ( (ch = getchr('1', '7')) == '7' ) { break; } if (ch == '1') { set_flag( conf->logon_type, LT_MESSAGE, onoff_req()); } if (ch == '2') { wprintf( L"1 - disabled\n" L"2 - display \"*\"\n"); if (getchr('1', '2') == '2') { conf->logon_type |= LT_DSP_PASS; } else { conf->logon_type &= ~LT_DSP_PASS; } } if (ch == '3') { wprintf(L"Enter new prompt text: "); s_gets(conf->eps_msg, sizeof(conf->eps_msg)); } if (ch == '4') { wchar_t path[MAX_PATH]; u8 *keyfile; u32 keysize; wprintf(L"Please enter path to keyfile: "); zeroauto(&conf->emb_key, sizeof(conf->emb_key)); conf->logon_type &= ~LT_EMBED_KEY; conf->logon_type |= LT_GET_PASS; if (s_wgets(path, sizeof(path)) != 0) { if (load_file(path, &keyfile, &keysize) != ST_OK) { wprintf(L"keyfile not loaded\n"); Sleep(1000); } else { if (keysize != 64) { wprintf(L"Embedded keyfile must be 64byte size\n"); Sleep(1000); } else { wprintf( L"1 - Use embedded keyfile and password\n" L"2 - Use only embedded keyfile\n"); if (getchr('1', '2') == '2') { conf->logon_type &= ~LT_GET_PASS; } autocpy(&conf->emb_key, keyfile, sizeof(conf->emb_key)); conf->logon_type |= LT_EMBED_KEY; } zeromem(keyfile, keysize); free(keyfile); } } } if (ch == '5') { wprintf(L"Enter new timeout in seconds or 0 to disable: "); if (wscanf(L"%d", &conf->timeout) == 0) { conf->timeout = 0; } set_flag( conf->options, OP_EPS_TMO, (conf->timeout != 0)); } if (ch == '6') { set_flag( conf->options, OP_TMO_STOP, onoff_req()); } } while (1); }
int main(int argc, char *argv[]) { char buffer[BUFSIZ]; wchar_t wbuffer[BUFSIZ]; char *buf; wchar_t *wbuf; FILE *f; off_t off; fpos_t pos; size_t size; int fd, r; char c; wchar_t wc; if ((fd = dup(1)) == -1) err(2, "dup"); if ((dup_stdout = fdopen(fd, "w")) == NULL) err(2, "fdopen"); if ((fd = mkstemp(filename)) == -1) err(2, "mkstemp"); if (write(fd, "0123456789\n\n", 12) != 12 || close(fd)) err(2, "write + close"); /* status */ TEST_UNCHANGED(fwide(f, 0)); TEST_NARROW(fwide(f, -1)); TEST_WIDE(fwide(f, 1)); TEST_UNCHANGED(feof(f)); TEST_UNCHANGED(ferror(f)); TEST_UNCHANGED(fileno(f)); TEST_UNCHANGED(clearerr(f)); /* flush and purge */ TEST_UNCHANGED(fflush(f)); TEST_UNCHANGED(fpurge(f)); /* positioning */ TEST_UNCHANGED(fgetpos(f, &pos)); TEST_UNCHANGED(fgetpos(f, &pos); fsetpos(f, &pos)); TEST_UNCHANGED(ftell(f)); TEST_UNCHANGED(ftello(f)); TEST_UNCHANGED(fseek(f, 1, SEEK_CUR)); TEST_UNCHANGED(fseek(f, 1, SEEK_SET)); TEST_UNCHANGED(fseek(f, 1, SEEK_END)); TEST_UNCHANGED(fseeko(f, 1, SEEK_CUR)); TEST_UNCHANGED(fseeko(f, 1, SEEK_SET)); TEST_UNCHANGED(fseeko(f, 1, SEEK_END)); TEST_UNCHANGED(rewind(f)); /* buffering */ TEST_UNCHANGED(setbuf(f, NULL)); TEST_UNCHANGED(setbuf(f, buffer)); TEST_UNCHANGED(setvbuf(f, buffer, _IONBF, BUFSIZ)); TEST_UNCHANGED(setvbuf(f, buffer, _IOLBF, BUFSIZ)); TEST_UNCHANGED(setvbuf(f, buffer, _IOFBF, BUFSIZ)); TEST_UNCHANGED(setvbuf(f, NULL, _IONBF, 0)); TEST_UNCHANGED(setvbuf(f, NULL, _IOLBF, 0)); TEST_UNCHANGED(setvbuf(f, NULL, _IOFBF, 0)); TEST_UNCHANGED(setbuffer(f, NULL, 0)); TEST_UNCHANGED(setbuffer(f, buffer, BUFSIZ)); TEST_UNCHANGED(setlinebuf(f)); /* locking */ TEST_UNCHANGED(flockfile(f);funlockfile(f)); TEST_UNCHANGED(ftrylockfile(f);funlockfile(f)); /* input */ TEST_NARROW(getc(f)); TEST_NARROW(getc_unlocked(f)); TEST_NARROW(fgetc(f)); TEST_NARROW(c = fgetc(f); ungetc(c, f)); TEST_NARROW(fgets(buffer, BUFSIZ, f)); TEST_NARROW(fscanf(f, "%s\n", buffer)); TEST_NARROW(fgetln(f, &size)); /* output */ TEST_NARROW(putc('c', f)); TEST_NARROW(putc_unlocked('c', f)); TEST_NARROW(fputc('c', f)); TEST_NARROW(fputs("foo", f)); TEST_NARROW(fprintf(f, "%s\n", "foo")); /* input from stdin */ TEST_NARROW_STD(stdin, getchar()); TEST_NARROW_STD(stdin, getchar_unlocked()); TEST_NARROW_STD(stdin, fgets(buffer, BUFSIZ, stdin)); TEST_NARROW_STD(stdin, scanf("%s\n", buffer)); /* output to stdout */ TEST_NARROW_STD(stdout, putchar('c')); TEST_NARROW_STD(stdout, putchar_unlocked('c')); TEST_NARROW_STD(stdout, puts("foo")); TEST_NARROW_STD(stdout, printf("foo")); /* word-size ops */ /* * fread and fwrite are specified as being implemented in * terms of fgetc() and fputc() and therefore must set the * stream orientation to narrow. */ TEST_NARROW(fread(buffer, 4, BUFSIZ / 4, f)); TEST_NARROW(fwrite(buffer, 4, BUFSIZ / 4, f)); /* * getw() and putw() aren't specified anywhere but logically * should behave the same as fread/fwrite. Not all OSes agree: * Solaris 10 has them not changing the orientation. */ TEST_NARROW(getw(f)); TEST_NARROW(putw(1234, f)); /* WIDE CHAR TIME! */ /* input */ TEST_WIDE(getwc(f)); TEST_WIDE(fgetwc(f)); TEST_WIDE(wc = fgetwc(f); ungetwc(wc, f)); TEST_WIDE(fgetws(wbuffer, BUFSIZ, f)); TEST_WIDE(fwscanf(f, L"%s\n", wbuffer)); /* output */ TEST_WIDE(putwc(L'c', f)); TEST_WIDE(fputwc(L'c', f)); TEST_WIDE(fputws(L"foo", f)); TEST_WIDE(fwprintf(f, L"%s\n", L"foo")); /* input from stdin */ TEST_WIDE_STD(stdin, getwchar()); TEST_WIDE_STD(stdin, wscanf(L"%s\n", wbuffer)); /* output to stdout */ TEST_WIDE_STD(stdout, putwchar(L'c')); TEST_WIDE_STD(stdout, wprintf(L"foo")); /* memory streams */ f = open_memstream(&buf, &size); if (!((r = fwide(f, 0)) < 0)) fail(__LINE__, r, "<", "open_memstream()"); fclose(f); f = open_wmemstream(&wbuf, &size); if (!((r = fwide(f, 0)) > 0)) fail(__LINE__, r, ">", "open_wmemstream()"); fclose(f); /* random stuff? */ TEST_UNCHANGED_STD(stderr, perror("foo")); remove(filename); if (failures) exit(1); exit(0); }
//----------------------------------------------------------------------------- int main(int argc, char *argv[]) { mgl_suppress_warn(true); mglGraph gr; mglParse p(true); char buf[2048], iname[256]="", oname[256]=""; std::vector<std::wstring> var; std::wstring str; bool none=false; while(1) { int ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hno:L:C:A:s:S:q:v:g:"); if(ch>='1' && ch<='9') p.AddParam(ch-'0', optarg); else if(ch=='s') { setlocale(LC_CTYPE, ""); FILE *fp = fopen(optarg,"r"); if(fp) { wchar_t ch; while(!feof(fp) && size_t(ch=fgetwc(fp))!=WEOF) str.push_back(ch); fclose(fp); str += L"\n"; } } else if(ch=='n') none = true; else if(ch=='L') setlocale(LC_CTYPE, optarg); else if(ch=='S') mgl_set_size_scl(atof(optarg)); else if(ch=='q') gr.SetQuality(atoi(optarg)); else if(ch=='v') p.SetVariant(atoi(optarg)); else if(ch=='g') gr.Gray(atoi(optarg)); else if(ch=='A') { std::wstring str; for(size_t i=0;optarg[i];i++) str.push_back(optarg[i]); var.push_back(str); } else if(ch=='C') { double v1,v2,dv=1,v; int res=sscanf(optarg,"%lg:%lg:%lg",&v1,&v2,&dv); if(res<3) dv=1; wchar_t num[64]; for(v=v1;v<=v2;v+=dv) { mglprintf(num,64,L"%g",v); var.push_back(num); } } else if(ch=='h' || (ch==-1 && optind>=argc)) { printf("mglconv convert mgl script to bitmap png file.\nCurrent version is 2.%g\n",MGL_VER2); printf("Usage:\tmglconv [parameter(s)] scriptfile\n"); printf( "\t-1 str set str as argument $1 for script\n" "\t... ...\n" "\t-9 str set str as argument $9 for script\n" "\t-L loc set locale to loc\n" "\t-s fname set MGL script for setting up the plot\n" "\t-S val set scaling factor for images\n" "\t-q val set quality for output (val=0...9)\n" "\t-g val set gray-scale mode (val=0|1)\n" "\t-v val set variant of arguments\n" "\t-o name set output file name\n" "\t-n no default output (script should save results by itself)\n" "\t-A val add animation value val\n" "\t-C n1:n2:dn add animation value in range [n1,n2] with step dn\n" "\t-C n1:n2 add animation value in range [n1,n2] with step 1\n" "\t- get script from standard input\n" "\t-h print this message\n" ); return 0; } else if(ch=='o') strncpy(oname, optarg,256); else if(ch==-1 && optind<argc) { strncpy(iname, argv[optind][0]=='-'?"":argv[optind],256); break; } } if(*oname==0) { strncpy(oname,*iname?iname:"out",250); strcat(oname,".png"); } else none = false; mgl_ask_func = mgl_ask_gets; // prepare for animation setlocale(LC_CTYPE, ""); FILE *fp = *iname?fopen(iname,"r"):stdin; if(!fp) { printf("No file for MGL script\n"); return 0; } wchar_t cw; while(!feof(fp) && size_t(cw=fgetwc(fp))!=WEOF) str.push_back(cw); if(*iname) fclose(fp); size_t n; for(size_t i=0;;) // collect exact values { n = str.find(L"##a ",i); if (n == mnpos) break; i = n+4; var.push_back(str.substr(i,str.find('\n',i))); } n = str.find(L"##c "); if (n != mnpos) { double v1,v2,dv,v; wscanf(str.c_str()+n+4,L"%lg%lg%lg",&v1,&v2,&dv); wchar_t ss[64]; for(v=v1;v<=v2;v+=dv) { mglprintf(ss,64,L"%g",v); var.push_back(ss); } } bool gif = !strcmp(oname+strlen(oname)-4,".gif"); gr.SetSize(600,400); // specially call for "S" option if(var.size()>1) // there is animation { if(gif) gr.StartGIF(oname); for(size_t i=0;i<var.size();i++) { gr.NewFrame(); printf("frame %zu for $0 = \"%ls\"\n",i,var[i].c_str()); p.AddParam(0,var[i].c_str()); p.Execute(&gr,str.c_str()); if(gr.Message()[0]) printf("%s\n",gr.Message()); gr.EndFrame(); snprintf(buf,2048,"%s-%zu",oname,i); buf[2047]=0; if(!gif) gr.WriteFrame(buf); } if(gif) gr.CloseGIF(); } else { p.Execute(&gr,str.c_str()); if(gr.Message()[0]) printf("%s\n",gr.Message()); if(!none) gr.WriteFrame(oname); } if(!mglGlobalMess.empty()) printf("%s",mglGlobalMess.c_str()); if(!none || gif) printf("Write output to %s\n",oname); return 0; }
int main() { printf(" WI \n"); printf("------\n"); printf("\n"); std::vector<WCHAR> commandBuffer(1000 + 1, L'\0'); std::vector<WCHAR> trashBuffer(1000 + 1, L'\0'); std::vector<WCHAR> textBuffer(1024 + 1, L'\0'); int lineNumber = 1; size_t linePositionInText = 0; for (;;) { printf("%d: ", lineNumber); std::fill(commandBuffer.begin(), commandBuffer.end(), L'\0'); wscanf(L"%1000[a-zA-Z0-9?,.!()%:- ]", commandBuffer.data()); std::fill(trashBuffer.begin(), trashBuffer.end(), L'\0'); fgetws(trashBuffer.data(), trashBuffer.size(), stdin); //NORMAL MAY BE if (wcscmp(commandBuffer.data(), L":done") == 0) break; if (wcsncmp(commandBuffer.data(), L":line ", 6) == 0) { swscanf(commandBuffer.data() + 6, L"%d", &lineNumber); if (lineNumber < 0 || lineNumber > 1000) return -1; if (lineNumber == 0) { lineNumber = 1; } linePositionInText = 0; for (int i = 0; i < lineNumber && linePositionInText < textBuffer.size(); linePositionInText++) { if (textBuffer[linePositionInText] == L'\n') { i++; } } continue; } // replace arguments int cnt = 0; for (WCHAR* ptr2 = commandBuffer.data();;) { ptr2 = wcschr(ptr2, L'%'); if (ptr2 == NULL) break; if (ptr2[1] == L'%') //%%??? { if (ptr2[2] == L'x' || ptr2[2] == L's' || ptr2[2] == L'i' || ptr2[2] == L'd' || ptr2[2] == L'u' || ptr2[2] == L'l') break; for (int i = 0; i < wcslen(ptr2); i++) { ptr2[i] = ptr2[i + 1]; //1???? } ptr2--; if (ptr2 < commandBuffer.data()) break; //!!!! } else if (ptr2[1] == L'l') { cnt++; ptr2[1] = L'd'; } else { for (int i = wcslen(ptr2) - 1; i >= 0; i--) { ptr2[i + 1] = ptr2[i]; } } if (ptr2 >= commandBuffer.data() + commandBuffer.size() - 1) break; //!! ptr2 += 2; } std::vector<int> arg_list(cnt, lineNumber); int space = _vsnwprintf(NULL, 0, commandBuffer.data(), reinterpret_cast<va_list>(arg_list.data())); textBuffer.insert(textBuffer.begin() + linePositionInText, space + 1, L'\0'); _vsnwprintf(&textBuffer[linePositionInText], space, commandBuffer.data(), reinterpret_cast<va_list>(arg_list.data())); textBuffer[linePositionInText + space] = L'\n'; linePositionInText += space + 1; lineNumber++; } wprintf(L"\n\n"); wprintf(L"THE FINAL TEXT\n"); wprintf(L"==============\n"); wprintf(L"%s\n\n", textBuffer.data()); return -14; }
//----------------------------------------------------------------------------- int main(int narg, char **arg) { mglGraphZB gr; mglParse p(true); if(narg==1) { printf("mgl2gif convert mgl script to bitmap gif file.\n"); printf("Current version is 1.%g\n",MGL_VERSION); printf("Usage:\tmgl2gif scriptfile [outputfile parameter(s)]\n"); printf("\tParameters have format \"-Nval\".\n"); printf("\tHere N=0,1...9 is parameter ID and val is its value.\n"); printf("\tOption -Lval set locale to val.\n"); printf("\tOption -Aval add value of $0 for making animation.\n"); printf("\tOption -Cn1:n2 cycle from n1 to n2 for making animation.\n"); } else { Str *head=0, *cur=0; FILE *fp = fopen(arg[1],"rb"); if(fp==0) { printf("Couldn't open file %s\n",arg[1]); return 1; } wchar_t str[8192]; char fname[2048], buf[2048]; for(long i=2;i<narg;i++) // add arguments for the script { if(arg[i][0]=='-' && arg[i][1]>='0' && arg[i][1]<='9') p.AddParam(arg[i][1]-'0',arg[i]+2); if(arg[i][0]=='-' && arg[i][1]=='L') setlocale(LC_CTYPE, arg[i]+2); if(arg[i][0]=='-' && arg[i][1]=='A') { if(cur) cur = new Str(cur,arg[i]+2); else head = cur = new Str(0,arg[i]+2); } if(arg[i][0]=='-' && arg[i][1]=='C') { int n,n1,n2; sscanf(arg[i]+2,"%d:%d",&n1,&n2); char str[64]; for(n=n1;n<n2;n++) { sprintf(str,"%d",n); if(cur) cur = new Str(cur,str); else head = cur = new Str(0,str); } } } if(narg>2 && arg[2][0]!='-') strcpy(fname,arg[2]); else { strcpy(fname,arg[1]); strcat(fname,".gif"); printf("Write output to %s\n",fname); } // first read animation parameters from file while(!feof(fp)) { if(!fgetws(str,8192,fp)) break; wcstrim_mgl(str); if(str[0]=='#' && str[1]=='#' && str[2]=='a' && str[3]==' ') { if(cur) cur = new Str(cur,str+4); else head = cur = new Str(0,str+4); } if(str[0]=='#' && str[1]=='#' && str[2]=='c' && str[3]==' ') { float v1,v2,dv,v; wscanf(str+4,"%g %g %g",&v1,&v2,&dv); char ss[64]; for(v=v1;v<v2;v+=dv) { sprintf(ss,"%g",v); if(cur) cur = new Str(cur,ss); else head = cur = new Str(0,ss); } } } // now execute it and save gr.Message = buf; *buf=0; if(head) // as animated gif { gr.StartGIF(fname); for(cur = head;cur!=0;cur=cur->next) { fseek(fp,0,SEEK_SET); gr.NewFrame(); p.AddParam(0,cur->str); p.Execute(&gr,fp,true); gr.EndFrame(); } gr.CloseGIF(); } else // simple gif { fseek(fp,0,SEEK_SET); p.Execute(&gr,fp,true); gr.WriteGIF(fname); } fclose(fp); } return 0; }
int SetSerialState(int nPortNum, int args, WCHAR *argv[]) { int arg; int value; DCB dcb; COMMTIMEOUTS CommTimeouts; WCHAR buf[MAX_COMPARAM_LEN+1]; if (SerialPortQuery(nPortNum, &dcb, &CommTimeouts, FALSE)) { for (arg = 2; arg < args; arg++) { if (wcslen(argv[arg]) > MAX_COMPARAM_LEN) { wprintf(L"Invalid parameter (too long) - %s\n", argv[arg]); return 1; } wcscpy(buf, argv[arg]); _wcslwr(buf); if (wcsstr(buf, L"baud=")) { wscanf(buf+5, L"%lu", &dcb.BaudRate); } else if (wcsstr(buf, L"parity=")) { if (wcschr(buf, L'D')) dcb.Parity = 1; else if (wcschr(buf, L'V')) dcb.Parity = 2; else if (wcschr(buf, L'M')) dcb.Parity = 3; else if (wcschr(buf, L'S')) dcb.Parity = 4; else dcb.Parity = 0; } else if (wcsstr(buf, L"data=")) { wscanf(buf+5, L"%lu", &dcb.ByteSize); } else if (wcsstr(buf, L"stop=")) { if (wcschr(buf, L'5')) dcb.StopBits = 1; else if (wcschr(buf, L'2')) dcb.StopBits = 2; else dcb.StopBits = 0; } else if (wcsstr(buf, L"to=")) // to=on|off { value = ExtractModeSerialParams(buf); if (value != -1) { } else { goto invalid_serial_parameter; } } else if (wcsstr(buf, L"xon=")) // xon=on|off { value = ExtractModeSerialParams(buf); if (value != -1) { dcb.fOutX = value; dcb.fInX = value; } else { goto invalid_serial_parameter; } } else if (wcsstr(buf, L"odsr=")) // odsr=on|off { value = ExtractModeSerialParams(buf); if (value != -1) { dcb.fOutxDsrFlow = value; } else { goto invalid_serial_parameter; } } else if (wcsstr(buf, L"octs=")) // octs=on|off { value = ExtractModeSerialParams(buf); if (value != -1) { dcb.fOutxCtsFlow = value; } else { goto invalid_serial_parameter; } } else if (wcsstr(buf, L"dtr=")) // dtr=on|off|hs { value = ExtractModeSerialParams(buf); if (value != -1) { dcb.fDtrControl = value; } else { goto invalid_serial_parameter; } } else if (wcsstr(buf, L"rts=")) // rts=on|off|hs|tg { value = ExtractModeSerialParams(buf); if (value != -1) { dcb.fRtsControl = value; } else { goto invalid_serial_parameter; } } else if (wcsstr(buf, L"idsr=")) // idsr=on|off { value = ExtractModeSerialParams(buf); if (value != -1) { dcb.fDsrSensitivity = value; } else { goto invalid_serial_parameter; } } else { invalid_serial_parameter:; wprintf(L"Invalid parameter - %s\n", buf); return 1; } } SerialPortQuery(nPortNum, &dcb, &CommTimeouts, TRUE); } return 0; }
int main() { WCHAR *text; WCHAR temp[1001] = { 0 }; WCHAR temp2[1001] = { 0 }; printf(" WI \n"); printf("------\n"); printf("\n"); int size = 1024; //text = (WCHAR *)realloc(NULL, size << 1); text = (WCHAR *)calloc(1, (size << 1) + 2); text[0] = 0; int curl = 1; WCHAR *ptr = text; while (-1) { printf("%d: ", curl); memset(temp, 0, 1001); wscanf(L"%1000[a-zA-Z0-9?,.!()%:- ]", temp); fgetws(temp2, (sizeof(temp2)/ sizeof(temp2[0])) - 1, stdin); //NORMAL MAY BE if (wcscmp(temp, L":done") == 0) break; if (wcsncmp(temp, L":line ", 6) == 0) { swscanf(temp + 6, L"%d", &curl); if (curl < 0) return -2; if (curl >= (size << 1)) return -3; if (curl == 0) curl = 1; ptr = text; for (int i = 0; i < curl; ptr++) //for (int i = 0; i < curl || i < sizeof(text) / sizeof(text[0]); ptr++) if (*ptr == L'\n') i++; continue; } // replace arguments WCHAR *ptr2 = temp; int cnt = 0; while (-2) { ptr2 = wcschr(ptr2, L'%'); if (ptr2 == NULL) break; if (ptr2[1] == L'%') //%%??? { for (int i = 0; i < wcslen(ptr2); i++) ptr2[i] = ptr2[i+1]; //1???? ptr2--; } else if (ptr2[1] == L'l') { cnt++; ptr2[1] = L'd'; } else for (int i = wcslen(ptr2); i >= 0; i--) ptr2[i + 1] = ptr2[i]; ptr2 += 2; } for (int i = 0; i < cnt; i++) __asm push curl; int space = _snwprintf(NULL, 0, temp); int temp3 = cnt << 2; __asm add esp, temp3; // reallocate if (((wcslen(text) + space + 1) << 1) > (size << 1) - 2) { text = (WCHAR *)realloc(text, (wcslen(text) + space + 1) << 1); size = wcslen(text) + space + 1; } // move for (int i = wcslen(ptr); i >= 0; i--) ptr[i + space + 1] = ptr[i]; for (int i = 0; i < cnt; i++) __asm push curl; _snwprintf(ptr, space, temp); temp3 = cnt << 2; __asm add esp, temp3; ptr[space] = L'\n'; ptr += space + 1; curl++; } wprintf(L"\n\n"); wprintf(L"THE FINAL TEXT\n"); wprintf(L"==============\n"); wprintf(L"%s\n\n", text); return -14; }
int main() { // mbstate_t comes from the underlying C library; it is defined (in C99) as: // a complete object type other than an array type that can hold the conversion // state information necessary to convert between sequences of multibyte // characters and wide characters #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-braces" #endif mbstate_t mb = {0}; #if defined(__clang__) #pragma clang diagnostic pop #endif size_t s = 0; tm *tm = 0; wint_t w = 0; ::FILE* fp = 0; #ifdef __APPLE__ __darwin_va_list va; #else __builtin_va_list va; #endif char* ns = 0; wchar_t* ws = 0; static_assert((std::is_same<decltype(fwprintf(fp, L"")), int>::value), ""); static_assert((std::is_same<decltype(fwscanf(fp, L"")), int>::value), ""); static_assert((std::is_same<decltype(swprintf(ws, s, L"")), int>::value), ""); static_assert((std::is_same<decltype(swscanf(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(vfwprintf(fp, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), ""); static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), ""); static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), ""); static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), ""); static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), ""); static_assert((std::is_same<decltype(wcstold(L"", (wchar_t**)0)), long double>::value), ""); static_assert((std::is_same<decltype(wcstol(L"", (wchar_t**)0, 0)), long>::value), ""); static_assert((std::is_same<decltype(wcstoll(L"", (wchar_t**)0, 0)), long long>::value), ""); static_assert((std::is_same<decltype(wcstoul(L"", (wchar_t**)0, 0)), unsigned long>::value), ""); static_assert((std::is_same<decltype(wcstoull(L"", (wchar_t**)0, 0)), unsigned long long>::value), ""); static_assert((std::is_same<decltype(wcscpy(ws, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsncpy(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscat(ws, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsncat(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscmp(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), ""); static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemmove(ws, L"", s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemset(ws, L' ', s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsftime(ws, s, L"", tm)), size_t>::value), ""); static_assert((std::is_same<decltype(btowc(0)), wint_t>::value), ""); static_assert((std::is_same<decltype(wctob(w)), int>::value), ""); static_assert((std::is_same<decltype(mbsinit(&mb)), int>::value), ""); static_assert((std::is_same<decltype(mbrlen("", s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(mbrtowc(ws, "", s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), ""); // These tests fail on systems whose C library doesn't provide a correct overload // set for wcschr, wcspbrk, wcsrchr, wcsstr, and wmemchr, unless the compiler is // a suitably recent version of Clang. #if !defined(__APPLE__) || defined(_LIBCPP_PREFERRED_OVERLOAD) static_assert((std::is_same<decltype(wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), ""); #endif #ifndef _LIBCPP_HAS_NO_STDIN static_assert((std::is_same<decltype(getwchar()), wint_t>::value), ""); static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), ""); static_assert((std::is_same<decltype(wscanf(L"")), int>::value), ""); #endif #ifndef _LIBCPP_HAS_NO_STDOUT static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), ""); static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), ""); static_assert((std::is_same<decltype(wprintf(L"")), int>::value), ""); #endif }