static void print(register Sfio_t* sp, register char* name, char* delim) { if (mbwide()) sfputr(sp, name, -1); else { #if CC_NATIVE != CC_ASCII register int c; register unsigned char* n2a; register unsigned char* a2n; register int aa; register int as; n2a = ccmap(CC_NATIVE, CC_ASCII); a2n = ccmap(CC_ASCII, CC_NATIVE); aa = n2a['A']; as = n2a[' ']; while (c = *name++) { c = n2a[c]; if (c & 0200) { c &= 0177; sfputc(sp, '?'); } if (c < as) { c += aa - 1; sfputc(sp, '^'); } c = a2n[c]; sfputc(sp, c); } #else register int c; while (c = *name++) { if (c & 0200) { c &= 0177; sfputc(sp, '?'); } if (c < ' ') { c += 'A' - 1; sfputc(sp, '^'); } sfputc(sp, c); } #endif } if (delim) sfputr(sp, delim, -1); }
static int initialize(void) { register int i; register Ucs_map_t* a; register Ucs_map_t* w; if (local.fatal) return -1; local.dtdisc.link = offsetof(Ucs_map_t, link); local.dtdisc.key = offsetof(Ucs_map_t, name); local.dtdisc.size = -1; if (!(w = (Ucs_map_t*)malloc(sizeof(Ucs_map_t) * (elementsof(ucs_attrs) + elementsof(ucs_names))))) { local.fatal = 1; return -1; } if (!(local.attrs = dtopen(&local.dtdisc, Dttree))) { free(w); local.fatal = 1; return -1; } if (!(local.names = dtopen(&local.dtdisc, Dttree))) { free(w); dtclose(local.attrs); local.fatal = 1; return -1; } for (i = 0; i < elementsof(ucs_attrs); i++, w++) { memcpy(w, &ucs_attrs[i], offsetof(Ucs_dat_t, table)); w->name = ucs_strings[ucs_attrs[i].table] + ucs_attrs[i].index; w->next = 0; dtinsert(local.attrs, w); } for (i = 0; i < elementsof(ucs_names); i++, w++) { memcpy(w, &ucs_names[i], offsetof(Ucs_dat_t, table)); w->name = ucs_strings[ucs_names[i].table] + ucs_names[i].index; w->next = 0; if (a = (Ucs_map_t*)dtsearch(local.names, w)) { while (a->next) a = a->next; a->next = w; } else dtinsert(local.names, w); } #if CC_NATIVE != CC_ASCII local.a2n = ccmap(CC_ASCII, CC_NATIVE); #endif return 0; }
static void banner(const char *string,const char *delim,int width) { register unsigned mask; register int c,i,n,j = strlen(string); register const char *cp,*dp; register unsigned char* map; map = ccmap(CC_NATIVE, CC_ASCII); if(j > width/8) error(ERROR_exit(1),"up to %d char%s per arg",width/8,(width/8)==1?"":"s"); for(i=0; i < CHAR_HEIGHT; i++) { dp = delim; for (n = 0, cp = string; c = ccmapchr(map, *cp++) & 0x07f; dp++) { if(*dp==0) dp = delim; if((mask = bandata[c][i])==0) { n += 8; continue; } for(j=0x80; j>0; j >>=1) { if(mask&j) { if(n) { sfnputc(sfstdout,' ',n); n = 0; } sfputc(sfstdout,*dp); } else n++; } } sfputc(sfstdout,'\n'); } }
int stracmp(const char* aa, const char* ab) { register unsigned char* a; register unsigned char* b; register unsigned char* m; register int c; register int d; if (!(m = ccmap(CC_NATIVE, CC_ASCII))) return strcmp(aa, ab); a = (unsigned char*)aa; b = (unsigned char*)ab; for (;;) { c = m[*a++]; if (d = c - m[*b++]) return d; if (!c) return 0; } }