mirror of
https://github.com/0intro/wmii
synced 2024-11-22 22:02:30 +03:00
Convert data from the fs to UTF-8, too. Fix a bug in synthetic configure notifies.
This commit is contained in:
parent
7fb69196ce
commit
c1dbb73648
@ -337,15 +337,12 @@ update_client_name(Client *c) {
|
|||||||
if(Xutf8TextPropertyToTextList(display, &name, &list, &n) == Success) {
|
if(Xutf8TextPropertyToTextList(display, &name, &list, &n) == Success) {
|
||||||
utfecpy(c->name, c->name+sizeof(c->name), list[0]);
|
utfecpy(c->name, c->name+sizeof(c->name), list[0]);
|
||||||
XFreeStringList(list);
|
XFreeStringList(list);
|
||||||
fprintf(stderr, "GotNetWMName: %x: %s\n", (uint)c->win.w, c->name);
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
XGetWMName(display, c->win.w, &name);
|
XGetWMName(display, c->win.w, &name);
|
||||||
if(name.nitems > 0) {
|
if(name.nitems > 0) {
|
||||||
str = toutf8((char*)name.value);
|
str = toutf8((char*)name.value);
|
||||||
utfecpy(c->name, c->name+sizeof(c->name), str);
|
utfecpy(c->name, c->name+sizeof(c->name), str);
|
||||||
fprintf(stderr, "GotWMName: %x: %s (was: %s)\n",
|
|
||||||
(uint)c->win.w, c->name, name.value);
|
|
||||||
free(str);
|
free(str);
|
||||||
XFree(name.value);
|
XFree(name.value);
|
||||||
}
|
}
|
||||||
@ -437,7 +434,7 @@ configure_client(Client *c) {
|
|||||||
f = c->sel;
|
f = c->sel;
|
||||||
if(!f)
|
if(!f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r = rectaddpt(f->crect, f->rect.min);
|
r = rectaddpt(f->crect, f->rect.min);
|
||||||
r = insetrect(r, -c->border);
|
r = insetrect(r, -c->border);
|
||||||
|
|
||||||
@ -445,7 +442,7 @@ configure_client(Client *c) {
|
|||||||
e.event = c->win.w;
|
e.event = c->win.w;
|
||||||
e.window = c->win.w;
|
e.window = c->win.w;
|
||||||
e.x = r.min.x;
|
e.x = r.min.x;
|
||||||
e.y = r.max.x;
|
e.y = r.min.y;
|
||||||
e.width = Dx(r);
|
e.width = Dx(r);
|
||||||
e.height = Dy(r);
|
e.height = Dy(r);
|
||||||
e.border_width = c->border;
|
e.border_width = c->border;
|
||||||
|
@ -216,4 +216,5 @@ int utfnlen(char*, long);
|
|||||||
char* utfrrune(char*, long);
|
char* utfrrune(char*, long);
|
||||||
char* utfrune(char*, long);
|
char* utfrune(char*, long);
|
||||||
char* utfutf(char*, char*);
|
char* utfutf(char*, char*);
|
||||||
|
char* toutf8n(const char*, int);
|
||||||
char* toutf8(const char*);
|
char* toutf8(const char*);
|
||||||
|
129
cmd/wmii/fs.c
129
cmd/wmii/fs.c
@ -41,7 +41,7 @@ struct FileId {
|
|||||||
Client *client;
|
Client *client;
|
||||||
Ruleset *rule;
|
Ruleset *rule;
|
||||||
CTuple *col;
|
CTuple *col;
|
||||||
} content;
|
} p;
|
||||||
uint id;
|
uint id;
|
||||||
uint index;
|
uint index;
|
||||||
Dirtab tab;
|
Dirtab tab;
|
||||||
@ -212,12 +212,17 @@ write_to_buf(Ixp9Req *r, void *buf, uint *len, uint max) {
|
|||||||
/* This should be moved to libixp */
|
/* This should be moved to libixp */
|
||||||
void
|
void
|
||||||
data_to_cstring(Ixp9Req *r) {
|
data_to_cstring(Ixp9Req *r) {
|
||||||
|
char *p;
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
i = r->ifcall.count;
|
i = r->ifcall.count;
|
||||||
if(!i || r->ifcall.data[i - 1] != '\n')
|
p = r->ifcall.data;
|
||||||
r->ifcall.data = erealloc(r->ifcall.data, ++i);
|
if(p[i - 1] == '\n')
|
||||||
|
i--;
|
||||||
|
|
||||||
|
r->ifcall.data = toutf8n(p, i);
|
||||||
assert(r->ifcall.data);
|
assert(r->ifcall.data);
|
||||||
r->ifcall.data[i - 1] = '\0';
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should be somewhere else */
|
/* Should be somewhere else */
|
||||||
@ -249,6 +254,7 @@ parse_colors(char **buf, int *buflen, CTuple *col) {
|
|||||||
|
|
||||||
char *
|
char *
|
||||||
message_root(char *message) {
|
message_root(char *message) {
|
||||||
|
Font *fn;
|
||||||
uint n;
|
uint n;
|
||||||
|
|
||||||
if(!strchr(message, ' ')) {
|
if(!strchr(message, ' ')) {
|
||||||
@ -281,10 +287,13 @@ message_root(char *message) {
|
|||||||
}
|
}
|
||||||
else if(!strncmp(message, "font ", 5)) {
|
else if(!strncmp(message, "font ", 5)) {
|
||||||
message += 5;
|
message += 5;
|
||||||
freefont(def.font);
|
fn = loadfont(message);
|
||||||
def.font = loadfont(message);
|
if(fn) {
|
||||||
assert(def.font);
|
freefont(def.font);
|
||||||
resize_bar(screen);
|
def.font = fn;
|
||||||
|
resize_bar(screen);
|
||||||
|
}else
|
||||||
|
return "can't load font";
|
||||||
}
|
}
|
||||||
else if(!strncmp(message, "border ", 7)) {
|
else if(!strncmp(message, "border ", 7)) {
|
||||||
message += 7;
|
message += 7;
|
||||||
@ -324,11 +333,11 @@ read_root_ctl() {
|
|||||||
void
|
void
|
||||||
respond_event(Ixp9Req *r) {
|
respond_event(Ixp9Req *r) {
|
||||||
FileId *f = r->fid->aux;
|
FileId *f = r->fid->aux;
|
||||||
if(f->content.buf) {
|
if(f->p.buf) {
|
||||||
r->ofcall.data = (void *)f->content.buf;
|
r->ofcall.data = (void *)f->p.buf;
|
||||||
r->ofcall.count = strlen(f->content.buf);
|
r->ofcall.count = strlen(f->p.buf);
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
f->content.buf = nil;
|
f->p.buf = nil;
|
||||||
}else{
|
}else{
|
||||||
r->aux = peventread;
|
r->aux = peventread;
|
||||||
peventread = r;
|
peventread = r;
|
||||||
@ -350,10 +359,10 @@ write_event(char *format, ...) {
|
|||||||
return;
|
return;
|
||||||
for(f=peventfid; f; f=f->next) {
|
for(f=peventfid; f; f=f->next) {
|
||||||
fi = f->fid->aux;
|
fi = f->fid->aux;
|
||||||
slen = fi->content.buf ? strlen(fi->content.buf) : 0;
|
slen = fi->p.buf ? strlen(fi->p.buf) : 0;
|
||||||
fi->content.buf = (char *) erealloc(fi->content.buf, slen + len + 1);
|
fi->p.buf = (char *) erealloc(fi->p.buf, slen + len + 1);
|
||||||
(fi->content.buf)[slen] = '\0';
|
(fi->p.buf)[slen] = '\0';
|
||||||
strcat(fi->content.buf, buffer);
|
strcat(fi->p.buf, buffer);
|
||||||
}
|
}
|
||||||
oeventread = peventread;
|
oeventread = peventread;
|
||||||
peventread = nil;
|
peventread = nil;
|
||||||
@ -407,7 +416,7 @@ lookup_file(FileId *parent, char *name)
|
|||||||
file = get_file();
|
file = get_file();
|
||||||
*last = file;
|
*last = file;
|
||||||
last = &file->next;
|
last = &file->next;
|
||||||
file->content.client = c;
|
file->p.client = c;
|
||||||
file->id = c->win.w;
|
file->id = c->win.w;
|
||||||
file->index = c->win.w;
|
file->index = c->win.w;
|
||||||
file->tab = *dir;
|
file->tab = *dir;
|
||||||
@ -423,7 +432,7 @@ lookup_file(FileId *parent, char *name)
|
|||||||
file = get_file();
|
file = get_file();
|
||||||
*last = file;
|
*last = file;
|
||||||
last = &file->next;
|
last = &file->next;
|
||||||
file->content.client = c;
|
file->p.client = c;
|
||||||
file->id = c->win.w;
|
file->id = c->win.w;
|
||||||
file->index = c->win.w;
|
file->index = c->win.w;
|
||||||
file->tab = *dir;
|
file->tab = *dir;
|
||||||
@ -439,7 +448,7 @@ lookup_file(FileId *parent, char *name)
|
|||||||
file = get_file();
|
file = get_file();
|
||||||
*last = file;
|
*last = file;
|
||||||
last = &file->next;
|
last = &file->next;
|
||||||
file->content.view = screen->sel;
|
file->p.view = screen->sel;
|
||||||
file->id = screen->sel->id;
|
file->id = screen->sel->id;
|
||||||
file->tab = *dir;
|
file->tab = *dir;
|
||||||
file->tab.name = estrdup("sel");
|
file->tab.name = estrdup("sel");
|
||||||
@ -450,7 +459,7 @@ lookup_file(FileId *parent, char *name)
|
|||||||
file = get_file();
|
file = get_file();
|
||||||
*last = file;
|
*last = file;
|
||||||
last = &file->next;
|
last = &file->next;
|
||||||
file->content.view = v;
|
file->p.view = v;
|
||||||
file->id = v->id;
|
file->id = v->id;
|
||||||
file->tab = *dir;
|
file->tab = *dir;
|
||||||
file->tab.name = estrdup(v->name);
|
file->tab.name = estrdup(v->name);
|
||||||
@ -459,12 +468,12 @@ lookup_file(FileId *parent, char *name)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FsDBars:
|
case FsDBars:
|
||||||
for(b=*parent->content.bar_p; b; b=b->next) {
|
for(b=*parent->p.bar_p; b; b=b->next) {
|
||||||
if(!name || !strcmp(name, b->name)) {
|
if(!name || !strcmp(name, b->name)) {
|
||||||
file = get_file();
|
file = get_file();
|
||||||
*last = file;
|
*last = file;
|
||||||
last = &file->next;
|
last = &file->next;
|
||||||
file->content.bar = b;
|
file->p.bar = b;
|
||||||
file->id = b->id;
|
file->id = b->id;
|
||||||
file->tab = *dir;
|
file->tab = *dir;
|
||||||
file->tab.name = estrdup(b->name);
|
file->tab.name = estrdup(b->name);
|
||||||
@ -479,7 +488,7 @@ lookup_file(FileId *parent, char *name)
|
|||||||
*last = file;
|
*last = file;
|
||||||
last = &file->next;
|
last = &file->next;
|
||||||
file->id = 0;
|
file->id = 0;
|
||||||
file->content.ref = parent->content.ref;
|
file->p.ref = parent->p.ref;
|
||||||
file->index = parent->index;
|
file->index = parent->index;
|
||||||
file->tab = *dir;
|
file->tab = *dir;
|
||||||
file->tab.name = estrdup(file->tab.name);
|
file->tab.name = estrdup(file->tab.name);
|
||||||
@ -487,15 +496,15 @@ lookup_file(FileId *parent, char *name)
|
|||||||
switch(file->tab.type) {
|
switch(file->tab.type) {
|
||||||
case FsDBars:
|
case FsDBars:
|
||||||
if(!strcmp(file->tab.name, "lbar"))
|
if(!strcmp(file->tab.name, "lbar"))
|
||||||
file->content.bar_p = &screen[0].bar[BarLeft];
|
file->p.bar_p = &screen[0].bar[BarLeft];
|
||||||
else
|
else
|
||||||
file->content.bar_p = &screen[0].bar[BarRight];
|
file->p.bar_p = &screen[0].bar[BarRight];
|
||||||
break;
|
break;
|
||||||
case FsFColRules:
|
case FsFColRules:
|
||||||
file->content.rule = &def.colrules;
|
file->p.rule = &def.colrules;
|
||||||
break;
|
break;
|
||||||
case FsFTagRules:
|
case FsFTagRules:
|
||||||
file->content.rule = &def.tagrules;
|
file->p.rule = &def.tagrules;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(name) goto LastItem;
|
if(name) goto LastItem;
|
||||||
@ -530,7 +539,7 @@ fs_attach(Ixp9Req *r) {
|
|||||||
FileId *f = get_file();
|
FileId *f = get_file();
|
||||||
f->tab = dirtab[FsRoot][0];
|
f->tab = dirtab[FsRoot][0];
|
||||||
f->tab.name = estrdup("/");
|
f->tab.name = estrdup("/");
|
||||||
f->content.ref = nil;
|
f->p.ref = nil;
|
||||||
r->fid->aux = f;
|
r->fid->aux = f;
|
||||||
r->fid->qid.type = f->tab.qtype;
|
r->fid->qid.type = f->tab.qtype;
|
||||||
r->fid->qid.path = QID(f->tab.type, 0);
|
r->fid->qid.path = QID(f->tab.type, 0);
|
||||||
@ -595,13 +604,13 @@ fs_size(FileId *f) {
|
|||||||
return 0;
|
return 0;
|
||||||
case FsFColRules:
|
case FsFColRules:
|
||||||
case FsFTagRules:
|
case FsFTagRules:
|
||||||
return f->content.rule->size;
|
return f->p.rule->size;
|
||||||
case FsFKeys:
|
case FsFKeys:
|
||||||
return def.keyssz;
|
return def.keyssz;
|
||||||
case FsFCtags:
|
case FsFCtags:
|
||||||
return strlen(f->content.client->tags);
|
return strlen(f->p.client->tags);
|
||||||
case FsFprops:
|
case FsFprops:
|
||||||
return strlen(f->content.client->props);
|
return strlen(f->p.client->props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,12 +687,12 @@ fs_read(Ixp9Req *r) {
|
|||||||
else{
|
else{
|
||||||
switch(f->tab.type) {
|
switch(f->tab.type) {
|
||||||
case FsFprops:
|
case FsFprops:
|
||||||
write_buf(r, f->content.client->props, strlen(f->content.client->props));
|
write_buf(r, f->p.client->props, strlen(f->p.client->props));
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFColRules:
|
case FsFColRules:
|
||||||
case FsFTagRules:
|
case FsFTagRules:
|
||||||
write_buf(r, f->content.rule->string, f->content.rule->size);
|
write_buf(r, f->p.rule->string, f->p.rule->size);
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFKeys:
|
case FsFKeys:
|
||||||
@ -691,15 +700,15 @@ fs_read(Ixp9Req *r) {
|
|||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFCtags:
|
case FsFCtags:
|
||||||
write_buf(r, f->content.client->tags, strlen(f->content.client->tags));
|
write_buf(r, f->p.client->tags, strlen(f->p.client->tags));
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFTctl:
|
case FsFTctl:
|
||||||
write_buf(r, f->content.view->name, strlen(f->content.view->name));
|
write_buf(r, f->p.view->name, strlen(f->p.view->name));
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFBar:
|
case FsFBar:
|
||||||
write_buf(r, f->content.bar->buf, strlen(f->content.bar->buf));
|
write_buf(r, f->p.bar->buf, strlen(f->p.bar->buf));
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFRctl:
|
case FsFRctl:
|
||||||
@ -719,7 +728,7 @@ fs_read(Ixp9Req *r) {
|
|||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFTindex:
|
case FsFTindex:
|
||||||
buf = (char *)view_index(f->content.view);
|
buf = (char *)view_index(f->p.view);
|
||||||
n = strlen(buf);
|
n = strlen(buf);
|
||||||
write_buf(r, buf, n);
|
write_buf(r, buf, n);
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
@ -755,7 +764,7 @@ fs_write(Ixp9Req *r) {
|
|||||||
switch(f->tab.type) {
|
switch(f->tab.type) {
|
||||||
case FsFColRules:
|
case FsFColRules:
|
||||||
case FsFTagRules:
|
case FsFTagRules:
|
||||||
write_to_buf(r, &f->content.rule->string, &f->content.rule->size, 0);
|
write_to_buf(r, &f->p.rule->string, &f->p.rule->size, 0);
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFKeys:
|
case FsFKeys:
|
||||||
@ -764,20 +773,20 @@ fs_write(Ixp9Req *r) {
|
|||||||
return;
|
return;
|
||||||
case FsFCtags:
|
case FsFCtags:
|
||||||
data_to_cstring(r);
|
data_to_cstring(r);
|
||||||
apply_tags(f->content.client, r->ifcall.data);
|
apply_tags(f->p.client, r->ifcall.data);
|
||||||
r->ofcall.count = r->ifcall.count;
|
r->ofcall.count = r->ifcall.count;
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFBar:
|
case FsFBar:
|
||||||
/* XXX: This should validate after each write */
|
/* XXX: This should validate after each write */
|
||||||
i = strlen(f->content.bar->buf);
|
i = strlen(f->p.bar->buf);
|
||||||
write_to_buf(r, &f->content.bar->buf, &i, 279);
|
write_to_buf(r, &f->p.bar->buf, &i, 279);
|
||||||
r->ofcall.count = i - r->ifcall.offset;
|
r->ofcall.count = i - r->ifcall.offset;
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
return;
|
return;
|
||||||
case FsFCctl:
|
case FsFCctl:
|
||||||
data_to_cstring(r);
|
data_to_cstring(r);
|
||||||
if((errstr = message_client(f->content.client, r->ifcall.data))) {
|
if((errstr = message_client(f->p.client, r->ifcall.data))) {
|
||||||
respond(r, errstr);
|
respond(r, errstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -786,7 +795,7 @@ fs_write(Ixp9Req *r) {
|
|||||||
return;
|
return;
|
||||||
case FsFTctl:
|
case FsFTctl:
|
||||||
data_to_cstring(r);
|
data_to_cstring(r);
|
||||||
if((errstr = message_view(f->content.view, r->ifcall.data))) {
|
if((errstr = message_view(f->p.view, r->ifcall.data))) {
|
||||||
respond(r, errstr);
|
respond(r, errstr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -796,14 +805,17 @@ fs_write(Ixp9Req *r) {
|
|||||||
case FsFRctl:
|
case FsFRctl:
|
||||||
data_to_cstring(r);
|
data_to_cstring(r);
|
||||||
{ uint n;
|
{ uint n;
|
||||||
char *toks[32];
|
char *p, *toks[32];
|
||||||
n = tokenize(toks, 32, r->ifcall.data, '\n');
|
|
||||||
|
p = toutf8n(r->ifcall.data, r->ifcall.count);
|
||||||
|
n = tokenize(toks, 32, p, '\n');
|
||||||
for(i = 0; i < n; i++) {
|
for(i = 0; i < n; i++) {
|
||||||
if(errstr)
|
if(errstr)
|
||||||
message_root(toks[i]);
|
message_root(toks[i]);
|
||||||
else
|
else
|
||||||
errstr = message_root(toks[i]);
|
errstr = message_root(toks[i]);
|
||||||
}
|
}
|
||||||
|
free(p);
|
||||||
}
|
}
|
||||||
if(screen->sel)
|
if(screen->sel)
|
||||||
focus_view(screen, screen->sel);
|
focus_view(screen, screen->sel);
|
||||||
@ -878,7 +890,7 @@ fs_create(Ixp9Req *r) {
|
|||||||
respond(r, Ebadvalue);
|
respond(r, Ebadvalue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
create_bar(f->content.bar_p, r->ifcall.name);
|
create_bar(f->p.bar_p, r->ifcall.name);
|
||||||
f = lookup_file(f, r->ifcall.name);
|
f = lookup_file(f, r->ifcall.name);
|
||||||
if(!f) {
|
if(!f) {
|
||||||
respond(r, Enofile);
|
respond(r, Enofile);
|
||||||
@ -908,7 +920,7 @@ fs_remove(Ixp9Req *r) {
|
|||||||
respond(r, Enoperm);
|
respond(r, Enoperm);
|
||||||
return;
|
return;
|
||||||
case FsFBar:
|
case FsFBar:
|
||||||
destroy_bar(f->next->content.bar_p, f->content.bar);
|
destroy_bar(f->next->p.bar_p, f->p.bar);
|
||||||
draw_bar(screen);
|
draw_bar(screen);
|
||||||
respond(r, nil);
|
respond(r, nil);
|
||||||
break;
|
break;
|
||||||
@ -919,7 +931,7 @@ void
|
|||||||
fs_clunk(Ixp9Req *r) {
|
fs_clunk(Ixp9Req *r) {
|
||||||
Client *c;
|
Client *c;
|
||||||
FidLink **fl, *ft;
|
FidLink **fl, *ft;
|
||||||
char *buf;
|
char *buf, *p, *q;
|
||||||
int i;
|
int i;
|
||||||
FileId *f = r->fid->aux;
|
FileId *f = r->fid->aux;
|
||||||
|
|
||||||
@ -930,10 +942,10 @@ fs_clunk(Ixp9Req *r) {
|
|||||||
|
|
||||||
switch(f->tab.type) {
|
switch(f->tab.type) {
|
||||||
case FsFColRules:
|
case FsFColRules:
|
||||||
update_rules(&f->content.rule->rule, f->content.rule->string);
|
update_rules(&f->p.rule->rule, f->p.rule->string);
|
||||||
break;
|
break;
|
||||||
case FsFTagRules:
|
case FsFTagRules:
|
||||||
update_rules(&f->content.rule->rule, f->content.rule->string);
|
update_rules(&f->p.rule->rule, f->p.rule->string);
|
||||||
for(c=client; c; c=c->next)
|
for(c=client; c; c=c->next)
|
||||||
apply_rules(c);
|
apply_rules(c);
|
||||||
update_views();
|
update_views();
|
||||||
@ -942,12 +954,19 @@ fs_clunk(Ixp9Req *r) {
|
|||||||
update_keys();
|
update_keys();
|
||||||
break;
|
break;
|
||||||
case FsFBar:
|
case FsFBar:
|
||||||
buf = f->content.bar->buf;
|
buf = f->p.bar->buf;
|
||||||
i = strlen(f->content.bar->buf);
|
i = strlen(buf);
|
||||||
parse_colors(&buf, &i, &f->content.bar->col);
|
buf = q = toutf8n(buf, i);
|
||||||
|
|
||||||
|
parse_colors(&buf, &i, &f->p.bar->col);
|
||||||
while(i > 0 && buf[i - 1] == '\n')
|
while(i > 0 && buf[i - 1] == '\n')
|
||||||
buf[--i] = '\0';
|
buf[--i] = '\0';
|
||||||
strncpy(f->content.bar->text, buf, sizeof(f->content.bar->text));
|
|
||||||
|
p = f->p.bar->text;
|
||||||
|
utfecpy(p, p+sizeof(f->p.bar->text), buf);
|
||||||
|
|
||||||
|
free(q);
|
||||||
|
|
||||||
draw_bar(screen);
|
draw_bar(screen);
|
||||||
break;
|
break;
|
||||||
case FsFEvent:
|
case FsFEvent:
|
||||||
@ -956,7 +975,7 @@ fs_clunk(Ixp9Req *r) {
|
|||||||
ft = *fl;
|
ft = *fl;
|
||||||
*fl = (*fl)->next;
|
*fl = (*fl)->next;
|
||||||
f = ft->fid->aux;
|
f = ft->fid->aux;
|
||||||
free(f->content.buf);
|
free(f->p.buf);
|
||||||
free(ft);
|
free(ft);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -320,18 +320,17 @@ utfutf(char *s1, char *s2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
toutf8(const char *str) {
|
toutf8n(const char *str, int nstr) {
|
||||||
static iconv_t cd;
|
static iconv_t cd;
|
||||||
char *buf, *pos;
|
char *buf, *pos;
|
||||||
int nbuf, nstr, bsize;
|
int nbuf, bsize;
|
||||||
|
|
||||||
if(cd == nil)
|
if(cd == nil)
|
||||||
cd = iconv_open("UTF-8", "");
|
cd = iconv_open("UTF-8", "");
|
||||||
iconv(cd, nil, nil, nil, nil);
|
iconv(cd, nil, nil, nil, nil);
|
||||||
|
|
||||||
nstr = strlen(str);
|
|
||||||
bsize = nstr * 1.25;
|
bsize = nstr * 1.25;
|
||||||
buf = emalloc(nbuf);
|
buf = emalloc(bsize);
|
||||||
pos = buf;
|
pos = buf;
|
||||||
nbuf = bsize-1;
|
nbuf = bsize-1;
|
||||||
while(iconv(cd, &str, &nstr, &pos, &nbuf) == -1)
|
while(iconv(cd, &str, &nstr, &pos, &nbuf) == -1)
|
||||||
@ -346,3 +345,8 @@ toutf8(const char *str) {
|
|||||||
*pos = '\0';
|
*pos = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
toutf8(const char *str) {
|
||||||
|
return toutf8n(str, strlen(str));
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user