📄 xinitct.c
字号:
register XrmQuark encoding; register ISORegisterState *ptr; register _CSID i; char esc[128]; if(state_encoding[1] == 0x25) { strcpy(esc, state_encoding); esc[4] = '0'; esc[5] = '0'; /* mask length */ state_encoding = esc; } encoding = XrmStringToQuark(state_encoding); for (i = 0, ptr = ISOStateTable; i < ISOStateTableNum; i++, ptr++) if (encoding == ptr->state_encoding) { return(i); } return(ND);}static _CSID_XcwEscGetIdFromLocale(xlocale, state_encoding) XLocale xlocale; char *state_encoding;{ Fontset *fontset; _CSID id; char esc[128]; if(!xlocale && !xlocale->xlc_db && !xlocale->xlc_db->lc_fontset) { return (_XcwEscGetId(state_encoding)); } fontset = xlocale->xlc_db->lc_fontset; if(state_encoding[1] == 0x25) { strcpy(esc, state_encoding); esc[4] = '0'; esc[5] = '0'; /* mask length */ state_encoding = esc; } for (id = 0; id < fontset->fs_num; id++) { if (!strcmp(state_encoding, fontset->fs_cset[id]->cs_des)) return(fontset->fs_cset[id]->cs_id); } return (_XcwEscGetId(state_encoding));}Bool_XcwEscSetStatus(xlocale, state_encoding) XLocale xlocale; char *state_encoding;{ _CSID id; if((id = _XcwEscGetIdFromLocale(xlocale, state_encoding)) == ND) return(False); ctSetGLorGR(xlocale, ISOStateTable[id].GLorGR); ctSetid(xlocale, id); return(True);} #ifdef not_useBool_XcwEscGetAll(xlocale, state_encoding, woffset) XLocale xlocale; char *state_encoding; wchar *woffset;{ _CSID id; if((id = _XcwEscGetIdFromLocale(xlocale, state_encoding)) == ND) return(False); ctSetGLorGR(xlocale, ISOStateTable[id].GLorGR); ctSetid(xlocale, id); *woffset = ISOStateTable[id].state_woffset; return(True);}int_XcwEscGetLength(state_encoding) char *state_encoding;{ _CSID id; if((id = _XcwEscGetId(state_encoding)) == ND) return 0; return ISOStateTable[id].state_length;}Bool_XcwEscGetName(state_encoding, state_name) char *state_encoding; char **state_name;{ _CSID id; if((id = _XcwEscGetId(state_encoding)) == ND) return(False); *state_name = ISOStateTable[id].nstate_name; return(True);} Bool_XcwEscGetWoffset(state_encoding, woffset) char *state_encoding; wchar *woffset;{ _CSID id; if((id = _XcwEscGetId(state_encoding)) == ND) return(False); *woffset = ISOStateTable[id].state_woffset; return(True);}/* * _XcwEscGetEncoding() * get same encoding sequence as caller passed, but the returned encoding * sequence stored in the internal table.*/Bool_XcwEscGetEncoding(passed_encoding, state_encoding) char *passed_encoding; char **state_encoding;{ _CSID id; if((id = _XcwEscGetId(passed_encoding)) == ND) return(False); *state_encoding = ISOStateTable[id].nstate_encoding; return(False);}#endif/* * _XcwGetAll() * calculate the minimun of difference between wc and woffset, then * return all items of ISOStateTable. **/_CSID_XcwGetWoffset(wc, woffset) wchar wc; wchar *woffset;{ register ISORegisterState *ptr = ISOStateTable; register wchar disp_min, new; _CSID ind, i; _CSID n = ISOStateTableNum;#define PosSub(s1, s2) (((s1) >= (s2)) ? ((s1) - (s2)) : ~0L) *woffset = ptr->state_woffset; wc &= ~0x7f; ind = CODESET0; disp_min = PosSub(wc, ptr->state_woffset); if (disp_min == (wchar) ~0L) { *woffset = 0; return(ND); } if (disp_min < 0x80) return(CODESET0); for (i = 1, ptr++; i < n; i++, ptr++) { if (ptr->state_length == 2) new = PosSub(wc & ~0x7f00, ptr->state_woffset); else new = PosSub(wc, ptr->state_woffset); if ((new >= 0) && (new < disp_min)) { *woffset = ptr->state_woffset; if (new < 0x80) return(i); ind = i; disp_min = new; } } return(ind);}_CSID_XcwGetWoffsetFromLocale(xlocale, wc, woffset) XLocale xlocale; wchar wc; wchar *woffset;{ register wchar disp_min; _CSID id; Fontset *fontset; if(!xlocale && !xlocale->xlc_db && !xlocale->xlc_db->lc_fontset) { *woffset = 0; return (_XcwGetWoffset(wc, woffset)); } fontset = xlocale->xlc_db->lc_fontset; wc &= ~0x7f; for (id = 0; id < fontset->fs_num; id++) { if (fontset->fs_cset[id]->cs_len == 2) disp_min = PosSub(wc & ~0x7f00, fontset->fs_cset[id]->cs_woff); else disp_min = PosSub(wc, fontset->fs_cset[id]->cs_woff); if (disp_min < 0x80) { *woffset = fontset->fs_cset[id]->cs_woff; return(fontset->fs_cset[id]->cs_id); } } return (_XcwGetWoffset(wc, woffset));#undef PosSub}static voidSetISOinfo(isoinfo, id) ISOStateInfo *isoinfo; _CSID id;{ ISORegisterState *ptr; ptr = ISOStateTable + id; isoinfo->code_bytes = ptr->state_length; if (ptr->C94orC96 == C96) { isoinfo->code_min = 0xa0; isoinfo->code_max = 0xff; } else if (ptr->GLorGR == GL) { if (id == CODESET0 || !strcmp(ptr->nstate_encoding, "\033(J")) /* ISO8859.1 GL or JISX0201 GL: for SPACE */ isoinfo->code_min = 0x20; else isoinfo->code_min = 0x21; isoinfo->code_max = 0x7e; } else { isoinfo->code_min = 0xa1; isoinfo->code_max = 0xfe; }}void_XcwGetAll(xlocale, wc, state_encoding, woffset, isoinfo) XLocale xlocale; wchar wc; char **state_encoding; wchar *woffset; ISOStateInfo *isoinfo;{ _CSID id; if ((id = _XcwGetWoffsetFromLocale(xlocale, wc, woffset)) == ND) return; ctSetGLorGR(xlocale, ISOStateTable[id].GLorGR); ctSetid(xlocale, id); *state_encoding = ISOStateTable[id].nstate_encoding; SetISOinfo(isoinfo, id);}int_XcwGetLength(wc) wchar wc;{ wchar woffset; _CSID id; id = _XcwGetWoffset(wc, &woffset); if(id == ND) return(-1); return (ISOStateTable[id].state_length);}#ifdef not_usevoid_XcwGetName(xlocale, wc) XLocale xlocale; wchar wc;{ wchar woffset; _CSID id; if ((id = _XcwGetWoffsetFromLocale(xlocale, wc, woffset)) == ND) return; if (ISOStateTable[id].GLorGR == GL) ctSetGLid(xlocale, id); else ctSetGRid(xlocale, id);}void_XcwGetEncoding(wc, state_encoding) wchar wc; char **state_encoding;{ wchar woffset; _CSID id; id = _XcwGetWoffset(wc, &woffset); if(id == ND) return; *state_encoding = ISOStateTable[id].nstate_encoding;}#endif/* * _XcwCheckDefaultState(): * check whether the isostate is default encoding, both GL and GR of * Latin-1. * It will be called by conversion function CT->WC.*/Bool_XcwCheckDefaultState(xlocale) XLocale xlocale;{ if ((xlocale->ct_state & 0xffff) == ((CODESET1 << 8) | CODESET0)) return(True); else return(False);}/* * get items of RegisterTable with the index ct_state.*/Bool_XcwIdCheck(xlocale) XLocale xlocale;{ if ((ctGetGLid(xlocale) >= ISOStateTableNum) || (ctGetGRid(xlocale) >= ISOStateTableNum)) return(False); return(True);}Bool_XcwIdGetAll(xlocale, woffset, isoinfo) XLocale xlocale; wchar *woffset; ISOStateInfo *isoinfo;{ _CSID id; id = ctGetid(xlocale); if (id >= ISOStateTableNum) return(False); *woffset = ISOStateTable[id].state_woffset; SetISOinfo(isoinfo, id); return(True);}int_XcwIdGetLength(xlocale) XLocale xlocale;{ _CSID id; id = ctGetid(xlocale); if (id >= ISOStateTableNum) return(False); return ISOStateTable[id].state_length;}Bool_XcwIdGetEncoding(xlocale, state_encoding) XLocale xlocale; char **state_encoding;{ _CSID id; id = ctGetid(xlocale); if (id >= ISOStateTableNum) return(False); *state_encoding = ISOStateTable[id].nstate_encoding; return (True);}void_XcwGetDefaultEncoding(xlocale, state_encoding) XLocale xlocale; char *state_encoding;{ _CSID id; *state_encoding = 0; id = ctGetGLid(xlocale); if (id < ISOStateTableNum && id != 0) /* GL is not ISO8859.1 */ strcpy(state_encoding, ISOStateTable[0].nstate_encoding); id = ctGetGRid(xlocale); if (id < ISOStateTableNum && id != 1) /* GR is not ISO8859.1 */ strcat(state_encoding, ISOStateTable[1].nstate_encoding);}Bool_XcwIdGetWoffset(xlocale, woffset) XLocale xlocale; wchar *woffset;{ _CSID id; id = ctGetid(xlocale); if (id >= ISOStateTableNum) return(False); *woffset = ISOStateTable[id].state_woffset; return (True);}#ifdef not_usechar *_XcwIdGetName(xlocale) XLocale xlocale;{ _CSID id; id = ctGetid(xlocale); if (id >= ISOStateTableNum) return(NULL); return (ISOStateTable[id].nstate_name);}#endifvoid_XcwIdGetISOState(xlocale, isoinfo) XLocale xlocale; ISOStateInfo *isoinfo;{ SetISOinfo(isoinfo, ctGetid(xlocale));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -