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

« back to all changes in this revision

Viewing changes to fep/read.c

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2005-12-04 13:10:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051204131042-ktzc8b17zi7a3cw8
Tags: 1:0.4.9.1-1
* New upstream release
* libuim0-nox, libuim-nox-dev, and libuim0-dbg-nox is now obsolete.
  Because libuim0 does not depends on X11. They now become dummy package,
  therefore you can safely remove them.
* Add --enable-debug in configure again.
* debian/patches/08_fix_privilage_escalation_CVE_2005_3149: disabled.
* Fix Error on purge because update-uim-config is not found.
  (closes: Bug#339345)
* uim-qt: New package for Qt utilities for uim. qt-immodule does not
  contained yet because of Debian's Qt3 does not support immodule and
  because uim does not recognize libqt4-dev's headers properly. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
     may be used to endorse or promote products derived from this software
18
18
     without specific prior written permission.
19
19
 
20
 
  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
20
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
21
21
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
22
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
 
  ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
23
  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
24
24
  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
25
  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
26
  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31
31
 
32
32
*/
33
33
 
34
 
#if HAVE_CONFIG_H
 
34
#ifdef HAVE_CONFIG_H
35
35
#include "config.h"
36
36
#endif
37
37
#ifndef DEBUG
38
38
#define NDEBUG
39
39
#endif
40
 
#if HAVE_SYS_TIME_H
 
40
#ifdef HAVE_SYS_TIME_H
41
41
#include <sys/time.h>
42
42
#endif
43
 
#if HAVE_SYS_TYPES_H
 
43
#ifdef HAVE_SYS_TYPES_H
44
44
#include <sys/types.h>
45
45
#endif
46
 
#if HAVE_UNISTD_H
 
46
#ifdef HAVE_UNISTD_H
47
47
#include <unistd.h>
48
48
#endif
49
 
#if HAVE_STRING_H
 
49
#ifdef HAVE_STRING_H
50
50
#include <string.h>
51
51
#endif
52
 
#if HAVE_STDLIB_H
 
52
#ifdef HAVE_STDLIB_H
53
53
#include <stdlib.h>
54
54
#endif
55
55
 
56
56
#include "uim-fep.h"
57
57
#include "read.h"
58
58
 
59
 
char *unget_buf = NULL;
60
 
int buf_size = 0;
 
59
static char *s_unget_buf = NULL;
 
60
static int s_buf_size = 0;
61
61
 
62
62
/*
63
63
 * select
65
65
 */
66
66
int my_select(int n, fd_set *readfds, struct timeval *timeout)
67
67
{
68
 
  if (buf_size > 0) {
 
68
  if (s_buf_size > 0) {
69
69
    FD_ZERO(readfds);
70
 
    FD_SET(STDIN_FILENO, readfds);
 
70
    FD_SET(g_win_in, readfds);
71
71
    return 1;
72
72
  }
73
73
  return select(n, readfds, NULL, NULL, timeout);
79
79
 */
80
80
ssize_t read_stdin(void *buf, int count)
81
81
{
82
 
  if (buf_size > 0) {
83
 
    if (buf_size > count) {
84
 
      memcpy(buf, unget_buf, count);
85
 
      buf_size -= count;
86
 
      memmove(unget_buf, unget_buf + count, buf_size);
 
82
  if (s_buf_size > 0) {
 
83
    if (s_buf_size > count) {
 
84
      memcpy(buf, s_unget_buf, count);
 
85
      s_buf_size -= count;
 
86
      memmove(s_unget_buf, s_unget_buf + count, s_buf_size);
87
87
      return count;
88
88
    } else {
89
 
      int rval = buf_size;
90
 
      memcpy(buf, unget_buf, buf_size);
91
 
      buf_size = 0;
 
89
      int rval = s_buf_size;
 
90
      memcpy(buf, s_unget_buf, s_buf_size);
 
91
      s_buf_size = 0;
92
92
      return rval;
93
93
    }
94
94
  }
95
 
  return read(STDIN_FILENO, buf, count);
 
95
  return read(g_win_in, buf, count);
96
96
}
97
97
 
98
98
/*
103
103
  if (count <= 0) {
104
104
    return;
105
105
  }
106
 
  debug(("unget count = %d buf_size = %d\n", count, buf_size));
107
 
  unget_buf = realloc(unget_buf, buf_size + count);
108
 
  memcpy(unget_buf + buf_size, str, count);
109
 
  buf_size += count;
 
106
  debug(("unget count = %d s_buf_size = %d\n", count, s_buf_size));
 
107
  s_unget_buf = realloc(s_unget_buf, s_buf_size + count);
 
108
  memcpy(s_unget_buf + s_buf_size, str, count);
 
109
  s_buf_size += count;
110
110
}