/* * Compare this string to the given string */ int utf8_ptr::s_compare_to(const char *p1, size_t bytelen1, const char *p2, size_t bytelen2) { /* keep going until one or the other string runs out of bytes */ while (bytelen1 != 0 && bytelen2 != 0) { wchar_t c1, c2; size_t siz1, siz2; /* get the current character from each string */ c1 = s_getch(p1); c2 = s_getch(p2); /* compare them */ if (c1 > c2) return 1; else if (c1 < c2) return -1; /* get the size of each character */ siz1 = s_charsize(*p1); siz2 = s_charsize(*p2); /* decrement each counter by the byte size of this character */ bytelen1 -= siz1; bytelen2 -= siz2; /* advance to the next character in each string */ p1 += siz1; p2 += siz2; } /* * we didn't find any character differences, but one string is * longer than the other -- if they ran out at the same time, * they're identical; otherwise, the one that ran out first is the * lesser one */ if (bytelen2 != 0) { /* the first one ran out first, so the first one sorts earlier */ return -1; } else if (bytelen1 != 0) { /* the second one ran out first, so the first one sort later */ return 1; } else { /* they both ran out at the same time */ return 0; } }
static int nextkey(char *valinta) { int m; long time1,time2; // RS REM char x[LLENGTH]; extern int muste_help_running; // RS ADD time((time_t *)&time1); while (1) { if (*info_2) { if (sur_get_message(info_2,1)) { return(-9); } } if (sur_kbhit()) break; time((time_t *)&time2); if (difftime(time2,time1)>0.5) { headline(valinta); time1=time2; if (muste_get_R_int(".muste$exitpressed")) // RS 27.2.2013 { muste_set_R_int(".muste$exitpressed",0); return(CODE_EXIT); } } sur_sleep(10); } special=0; m=s_getch(); switch (m) { case EXTEND_CH: m=sur_getch_ext(); special=1; switch (m) { case CODE_EXIT: case CODE_RETURN: case CODE_RIGHT: case CODE_LEFT: case CODE_UP: case CODE_DOWN: case CODE_HOME: case CODE_INSERT: case CODE_INSERTL: case CODE_DELETE: case CODE_DELETEL: case CODE_ERASE: case CODE_NEXT: case CODE_PREV: case CODE_EXEC: case CODE_DISP: case CODE_PRE: case CODE_TOUCH: case CODE_DISK: case CODE_CODE: break; case CODE_BACKSP: if (!muste_help_running) m=CODE_LEFT; break; // RS ADD case CODE_REF: case CODE_MERGE: case CODE_COPY: case CODE_TAB: case CODE_TABS: case CODE_HELP: case CODE_SRCH: case CODE_ACTIV: case CODE_MOVE: case CODE_END: case CODE_WORDS: case CODE_SOFT_ON: case CODE_RIGHT2: case CODE_LEFT2: case CODE_UP2: case CODE_DOWN2: case CODE_SUCRO1: case CODE_SUCRO2: case CODE_SUCRO3: case CODE_SUCRO4: case CODE_SUCRO5: case CODE_SUCRO6: case CODE_SUCRO7: case CODE_SUCRO8: case CODE_REF_SET: case CODE_REXEC: case CODE_RIGHT3: case CODE_PASTE: case CODE_CLIPCOPY: break; default: m=32; break; } case CODE_RETURN: special=1; break; case CODE_BACKSP: special=1; m=CODE_LEFT; break; case CODE_EXEC: special=1; break; case CODE_TAB: special=1; break; default: break; } return(m); }