~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to xim/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-07-06 22:17:24 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060706221724-6sobw1fcsxj647hp
Tags: 1:1.1.0-1.2
* Non-maintainer upload.
* Added -Wno-cast-align to CFLAGS, as per the RM's recommendations:

  < vorlon> Sesse: -Wno-cast-align and to hell with it :P

  Really fixes FTBFS. (Really Closes: #375081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 
3
 
  Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
 
3
  Copyright (c) 2003-2006 uim Project http://uim.freedesktop.org/
4
4
 
5
5
  All rights reserved.
6
6
 
33
33
// XIM Server supporting CJK languages
34
34
// initialize many modules
35
35
 
36
 
#define _GNU_SOURCE // for asprintf on stdio.h with old glibc/gcc
37
 
 
38
36
#ifdef HAVE_CONFIG_H
39
 
# include "config.h"
 
37
# include <config.h>
40
38
#endif
41
39
 
42
40
#include <stdio.h>
151
149
 
152
150
        std::map<int, fd_watch_struct>::iterator it;
153
151
        int  fd_max = 0;
154
 
        for (it = fd_watch_stat.begin(); it != fd_watch_stat.end(); it++) {
 
152
        for (it = fd_watch_stat.begin(); it != fd_watch_stat.end(); ++it) {
155
153
            int fd = it->first;
156
154
            if (it->second.mask & READ_OK)
157
155
                FD_SET(fd, &rfds);
165
163
            continue;
166
164
        }
167
165
 
168
 
        for (it = fd_watch_stat.begin(); it != fd_watch_stat.end(); it++) {
 
166
        it = fd_watch_stat.begin();
 
167
        while (it != fd_watch_stat.end()) {
169
168
            int fd = it->first;
170
169
            if (FD_ISSET(fd, &rfds))
171
170
                it->second.fn(fd, READ_OK);
172
171
            if (FD_ISSET(fd, &wfds))
173
172
                it->second.fn(fd, WRITE_OK);
 
173
            // fd_watch_stat may be modified by above functions at
 
174
            // this point.  Since the behavior with incrementing
 
175
            // invalidated iterator is compiler dependent, use safer
 
176
            // way.
 
177
            it = fd_watch_stat.find(fd);
 
178
            if (it == fd_watch_stat.end())      // shouldn't happen
 
179
                break;
 
180
            ++it;
174
181
        }
175
182
    }
176
183
}
326
333
}
327
334
 
328
335
static void
329
 
xEventRead(int fd, int ev)
 
336
xEventRead(int /* fd */, int /* ev */)
330
337
{
331
 
    XFlush(XimServer::gDpy);
332
338
    check_pending_xevent();
333
339
}
334
340
 
396
402
    if (uim_info.empty())
397
403
        printf("  None.\n");
398
404
    else
399
 
        for (it = uim_info.begin(); it != uim_info.end(); it++)
 
405
        for (it = uim_info.begin(); it != uim_info.end(); ++it)
400
406
            printf("  %s (%s)\n", it->name, it->lang);
401
407
    
402
408
}
405
411
clear_uim_info()
406
412
{
407
413
    std::list<UIMInfo>::iterator it;
408
 
    for (it = uim_info.begin(); it != uim_info.end(); it++) {
 
414
    for (it = uim_info.begin(); it != uim_info.end(); ++it) {
409
415
        free(it->name);
410
416
        free(it->lang);
411
417
        free(it->desc);
485
491
    bool found = false;
486
492
    if (default_engine) {
487
493
        std::list<UIMInfo>::iterator it;
488
 
        for (it = uim_info.begin(); it != uim_info.end(); it++) {
 
494
        for (it = uim_info.begin(); it != uim_info.end(); ++it) {
489
495
            if (!strcmp(it->name, default_engine)) {
490
496
                found = true;
491
497
                break;
517
523
}
518
524
 
519
525
void
520
 
reload_uim(int x)
 
526
reload_uim(int /* x */)
521
527
{
522
528
    fprintf(stderr, "\nReloading uim...\n\n");
523
529
 
528
534
    std::map<Window, XimServer *>::iterator it;
529
535
    std::list<InputContext *>::iterator it_c;
530
536
 
531
 
    for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); it++) {
 
537
    for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); ++it) {
532
538
        XimServer *xs = it->second;
533
 
        for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); it_c++)
 
539
        for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); ++it_c)
534
540
            (*it_c)->clear();
535
541
    }
536
542
 
539
545
    get_uim_info();
540
546
    //print_uim_info();
541
547
 
542
 
    for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); it++) {
 
548
    for (it = XimServer::gServerMap.begin(); it != XimServer::gServerMap.end(); ++it) {
543
549
        XimServer *xs = it->second;
544
 
        for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); it_c++) {
 
550
        for (it_c = xs->ic_list.begin(); it_c != xs->ic_list.end(); ++it_c) {
545
551
            const char *engine = (*it_c)->get_engine_name();
546
552
            (*it_c)->createUimContext(engine);
547
553
        }
602
608
 
603
609
    // First, setup conversion engine selected by cmdline option or
604
610
    // "default-im-name" on ~/.uim.
605
 
    for (it = uim_info.begin(); it != uim_info.end(); it++) {
 
611
    for (it = uim_info.begin(); it != uim_info.end(); ++it) {
606
612
        if (strcmp(it->name, default_engine) == 0) {
607
613
            XimServer *xs = new XimServer(it->name, it->lang);
608
614
            res = xs->setupConnection(true);