~ubuntu-branches/ubuntu/precise/uim/precise

« back to all changes in this revision

Viewing changes to uim/bsdlook.c

  • Committer: Package Import Robot
  • Author(s): Ilya Barygin
  • Date: 2011-12-18 16:35:38 UTC
  • mfrom: (1.1.13) (15.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20111218163538-8ktir39z2mjpii8z
Tags: 1:1.7.1-3ubuntu1
* Merge from Debian testing (LP: #818199).
* Remaining changes:
  - debian/uim-qt.install: Fix plugin path for multiarch location.
* Dropped changes:
  - uim-applet-gnome removal (GNOME 3 applet is available)
  - 19_as-needed_compile_fix.dpatch (accepted into Debian package)
* translations.patch: add several files to POTFILE.in to prevent
  intltool-update failure.

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
        if (!ctx)
167
167
                return;
168
168
 
169
 
        if (ctx->front0 > 0 && munmap(ctx->front0, ctx->len) == -1)
 
169
        if ((uintptr_t)ctx->front0 > 0 && munmap(ctx->front0, ctx->len) == -1)
170
170
                perror("uim_look_finish");
171
171
 
172
172
        if (ctx->fd > 0)
192
192
        if ((ctx->front0 = ctx->front = mmap(NULL,
193
193
                    (size_t)sb.st_size, PROT_READ, MAP_PRIVATE, ctx->fd, (off_t)0)) == MAP_FAILED) {
194
194
                perror("uim_look_open_dict");
 
195
                ctx->front0 = ctx->front = 0;
195
196
        }
196
197
        ctx->len = (size_t)sb.st_size;
197
198
        ctx->back0 = ctx->back = ctx->front + sb.st_size;
203
204
uim_look(char *string, uim_look_ctx *ctx)
204
205
{
205
206
        int ch;
206
 
        char *readp, *writep;
 
207
        unsigned char *readp, *writep;
207
208
        int fflag = ctx->fflag, dflag = ctx->dflag;
208
209
 
209
210
        /* Reformat string to avoid doing it multiple times later. */
210
 
        for (readp = writep = string; (ch = *readp++) != '\0';) {
 
211
        for (readp = writep = (unsigned char *)string; (ch = *readp++) != '\0';) {
211
212
                if (fflag)
212
213
                        ch = FOLD(ch);
213
214
                if (dflag)
214
215
                        ch = DICT(ch);
215
216
                if (ch != NO_COMPARE)
216
 
                        *(writep++) = (char)ch;
 
217
                        *(writep++) = (unsigned char)ch;
217
218
        }
218
219
        *writep = '\0';
219
220
 
434
435
compare(char *s1, char *s2, uim_look_ctx *ctx)
435
436
{
436
437
        int ch;
437
 
        char *back = ctx->back;
 
438
        unsigned char *back = (unsigned char *)ctx->back;
438
439
        int fflag = ctx->fflag, dflag = ctx->dflag;
439
440
 
440
 
        for (; *s1 && s2 < back && *s2 != '\n'; ++s1, ++s2) {
441
 
                ch = *s2;
 
441
        for (; (unsigned char)*s1 && (unsigned char *)s2 < back && *s2 != '\n'; ++s1, ++s2) {
 
442
                ch = (unsigned char)*s2;
442
443
                if (fflag)
443
444
                        ch = FOLD(ch);
444
445
                if (dflag)
448
449
                        ++s2;           /* Ignore character in comparison. */
449
450
                        continue;
450
451
                }
451
 
                if (*s1 != ch)
452
 
                        return (*s1 < ch ? LESS : GREATER);
 
452
                if ((unsigned char)*s1 != ch)
 
453
                        return ((unsigned char)*s1 < ch ? LESS : GREATER);
453
454
        }
454
 
        return (*s1 ? GREATER : EQUAL);
 
455
        return ((unsigned char)*s1 ? GREATER : EQUAL);
455
456
}
456
457
 
457
458
#if 0