~ubuntu-branches/ubuntu/gutsy/skksearch/gutsy

« back to all changes in this revision

Viewing changes to debian/patches/db4.3.diff

  • Committer: Bazaar Package Importer
  • Author(s): Noritada Kobayashi
  • Date: 2007-04-23 23:31:41 UTC
  • Revision ID: james.westby@ubuntu.com-20070423233141-c4g4011ogbezfe0v
Tags: 0.0-14
* Switch the patch management system from dpatch to quilt.
* debian/patches/clean-build-errors-and-warnings.diff: A new patch to clean
  build errors and warnings from gcc (currently gcc 4.1.1).
* debian/skksearch.install: A new file to clean up the installation of
  debhelper-independently installed files.
* debian/skksearch.conf: Add an entry for SKK-JISYO.JIS2004, a new
  dictionary provided by the skkdic-extra package since its version
  20070411-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
db4.3.dpatch by Matej Vela <vela@debian.org>
 
2
 
 
3
Port to Berkeley DB 4.3.
 
4
Index: skksearch-0.0/dic_db.c
 
5
===================================================================
 
6
--- skksearch-0.0.orig/dic_db.c 2005-11-12 19:49:38.000000000 +0100
 
7
+++ skksearch-0.0/dic_db.c      2005-11-12 19:55:03.000000000 +0100
 
8
@@ -23,19 +23,21 @@
 
9
 
 
10
 /* BerkeleyDB environment */
 
11
 int env_initialized = 0;
 
12
-DB_ENV env;
 
13
-void errcall(const char *, char *);
 
14
+DB_ENV *env;
 
15
+void errcall(const DB_ENV *, const char *, const char *);
 
16
 
 
17
 
 
18
 struct dic *dic_db_open(struct dic *d, char *path) {
 
19
+  int ret;
 
20
   struct dic_db_internal *internal;
 
21
 
 
22
   if (!env_initialized) {
 
23
-    env.db_errcall = errcall;
 
24
-    if ((errno = db_appinit(NULL, NULL, &env, DB_USE_ENVIRON)) != 0) {
 
25
-      err(LOG_ERR, "dic_db_open: db_appinit failed\n");
 
26
+    if ((ret = db_env_create(&env, 0)) != 0
 
27
+       || (ret = env->open(env, NULL, 0, DB_USE_ENVIRON)) != 0) {
 
28
+      err(LOG_ERR, "dic_db_open: %s\n", db_strerror(ret));
 
29
       exit(1);
 
30
     }
 
31
+    env->set_errcall(env, errcall);
 
32
     env_initialized = 1;
 
33
   }
 
34
 
 
35
@@ -45,10 +47,10 @@
 
36
   }
 
37
   memset(internal, 0, sizeof(struct dic_db_internal));
 
38
 
 
39
-  if ((errno =
 
40
-       db_open(path, DB_UNKNOWN, DB_RDONLY, 0, &env, NULL, &(internal->db)))
 
41
-      != 0) {
 
42
-    err(LOG_ERR, "dic_db_open(%s): %s\n", path, strerror(errno));
 
43
+  if ((ret = db_create(&(internal->db), env, 0)) != 0
 
44
+      || (ret = internal->db->open(internal->db, NULL, path, NULL,
 
45
+                                  DB_UNKNOWN, DB_RDONLY, 0)) != 0) {
 
46
+    err(LOG_ERR, "dic_db_open(%s): %s\n", path, db_strerror(ret));
 
47
     exit(1);
 
48
   }
 
49
   d->internal = (void *)internal;
 
50
@@ -58,6 +60,7 @@
 
51
   }
 
52
 
 
53
 char *dic_db_search(struct dic *d, char *keystr, int keylen) {
 
54
+  int ret;
 
55
   struct dic_db_internal *internal = (struct dic_db_internal *)(d->internal);
 
56
   DB *db = internal->db;
 
57
   DBT key;
 
58
@@ -71,23 +74,24 @@
 
59
   data.ulen = DIC_BUFSIZE - 1; /* -1 for '\0' */
 
60
   data.flags = DB_DBT_USERMEM;
 
61
 
 
62
-  if ((errno = db->get(db, NULL, &key, &data, 0)) == DB_NOTFOUND) {
 
63
+  if ((ret = db->get(db, NULL, &key, &data, 0)) == DB_NOTFOUND) {
 
64
     return NULL;
 
65
-  } else if (errno == 0) {     /* found */
 
66
+  } else if (ret == 0) {       /* found */
 
67
     *((char *)(data.data) + data.size) = '\0';
 
68
     return (char *)(data.data);
 
69
   } else {
 
70
     err(LOG_WARNING, "dic_db_search: %s (may be too long entry)\n",
 
71
-       strerror(errno));
 
72
+       db_strerror(ret));
 
73
     return NULL;
 
74
   }
 
75
 }
 
76
 
 
77
 
 
78
 int dic_db_close(struct dic *d) {
 
79
+  int ret;
 
80
   DB *db = ((struct dic_db_internal *)(d->internal))->db;
 
81
-  if ((errno = db->close(db, 0)) != 0) {
 
82
-    err(LOG_ERR, "dic_db_close: %s\n", strerror(errno));
 
83
+  if ((ret = db->close(db, 0)) != 0) {
 
84
+    err(LOG_ERR, "dic_db_close: %s\n", db_strerror(ret));
 
85
     exit(1);
 
86
   }
 
87
   free(d->internal);
 
88
@@ -96,6 +100,6 @@
 
89
 }
 
90
 
 
91
 
 
92
-void errcall(const char *foo, char *message) {
 
93
+void errcall(const DB_ENV *dbenv, const char *foo, const char *message) {
 
94
   err(LOG_ERR, "dic_db: %s\n", message);
 
95
 }