From: tomo Date: Wed, 6 Aug 2003 10:25:43 +0000 (+0000) Subject: (chise_open_attribute_table): Encode '/' and '%' in argument `feature' X-Git-Tag: r0_1_1-pre1~15 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccdbb547059a3fa77008a6bca1e5aee5c3d2b68f;p=chise%2Flibchise.git (chise_open_attribute_table): Encode '/' and '%' in argument `feature' for file name. --- diff --git a/chise.c b/chise.c index 4681fe3..c24fd8e 100644 --- a/chise.c +++ b/chise.c @@ -229,16 +229,17 @@ chise_open_attribute_table (CHISE_Attribute_Table **db, { DB* dbase; int status; - int len; + int len, flen, i; int size; - char *db_file_name; + char *db_file_name, *sp; status = db_create (&dbase, NULL, 0); if (status) return -1; len = strlen (db_dir); - size = len + strlen (encoding) + strlen (feature) + 4; + flen = strlen (feature); + size = len + strlen (encoding) + flen * 3 + 4; db_file_name = alloca (size); strcpy (db_file_name, db_dir); if (db_file_name[len - 1] != '/') @@ -248,7 +249,21 @@ chise_open_attribute_table (CHISE_Attribute_Table **db, } strcat (db_file_name, encoding); strcat (db_file_name, "/"); - strcat (db_file_name, feature); + /* strcat (db_file_name, feature); */ + sp = &db_file_name[strlen (db_file_name)]; + for (i = 0; i < flen; i++) + { + int c = feature[i]; + + if ( (c == '/') || (c == '%') ) + { + sprintf (sp, "%%%02X", c); + sp += 3; + } + else + *sp++ = c; + } + *sp = '\0'; status = dbase->open (dbase, db_file_name, NULL, real_subtype, accessmask, modemask); if (status)