int compare(char *prefix, char *word) { char *p= prefix, *w= word; int cp, cw; do { do { if ((cp= *p++) == 0) return 0; if (!isascii(cp)) nonascii("prefix string"); } while (dflg && !isspace(cp) && !isalnum(cp)); if (dflg) { if (isspace(cp)) { while (isspace(*p)) p++; cp= ' '; } } if (fflg && isupper(cp)) cp= tolower(cp); do { if ((cw= *w++) == 0) return 1; if (!isascii(cw)) nonascii(wordlist); } while (dflg && !isspace(cw) && !isalnum(cw)); if (dflg) { if (isspace(cw)) { while (isspace(*w)) w++; cw= ' '; } } if (fflg && isupper(cw)) cw= tolower(cw); } while (cp == cw); return cp - cw; }
static HTREEITEM treeview_insert(treeview_faff * faff, int level, char *text, char *path) { // text will be the label of an Options dialog treeview item; // it is passed in here as the basename of path HTREEITEM newitem; if (nonascii(path)) { wchar * utext = cs__utftowcs(text); TVINSERTSTRUCTW ins; ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT); ins.hInsertAfter = faff->lastat[level]; ins.item.mask = TVIF_TEXT | TVIF_PARAM; ins.item.pszText = utext; //ins.item.cchTextMax = wcslen(utext) + 1; // ignored when setting ins.item.lParam = (LPARAM) path; // It is essential to also use TVM_INSERTITEMW here! newitem = (HTREEITEM)SendMessageW(faff->treeview, TVM_INSERTITEMW, 0, (LPARAM)&ins); //TreeView_SetUnicodeFormat((HWND)newitem, TRUE); // does not work free(utext); } else { TVINSERTSTRUCTA ins; ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT); ins.hInsertAfter = faff->lastat[level]; ins.item.mask = TVIF_TEXT | TVIF_PARAM; ins.item.pszText = text; //ins.item.cchTextMax = strlen(text) + 1; // ignored when setting ins.item.lParam = (LPARAM) path; //newitem = TreeView_InsertItem(faff->treeview, &ins); newitem = (HTREEITEM)SendMessageA(faff->treeview, TVM_INSERTITEMA, 0, (LPARAM)&ins); } if (level > 0) TreeView_Expand(faff->treeview, faff->lastat[level - 1], (level > 1 ? TVE_COLLAPSE : TVE_EXPAND)); faff->lastat[level] = newitem; for (int i = level + 1; i < 4; i++) faff->lastat[i] = null; return newitem; }
int main(int argc, char *argv[]) { void (*print)(int, int, int) = NULL; FILE *the_file = stdin; char *the_file_name = NULL; if (argc > 1) { if (argv[1][0] == '-') { print = myprint; if (argc > 2) { the_file_name = argv[2]; the_file = fopen(argv[2], "rb"); } } else { the_file_name = argv[1]; the_file = fopen(argv[1], "rb"); } } if (the_file == NULL) { if (the_file_name) perror(the_file_name); else fprintf(stderr, "Looks like stdin is NULL\n"); return -1; } if (argc > 2) printf("Scanning %s:\n", argv[2]); /* reverse logic for shell */ return !nonascii(the_file, print); }