persistentstorage/sql/SQLite364/main.c
branchRCL_3
changeset 6 5ffdb8f2067f
parent 0 08ec8eefde2f
equal deleted inserted replaced
2:6862383cf555 6:5ffdb8f2067f
  1206 /*
  1206 /*
  1207 ** Return UTF-16 encoded English language explanation of the most recent
  1207 ** Return UTF-16 encoded English language explanation of the most recent
  1208 ** error.
  1208 ** error.
  1209 */
  1209 */
  1210 const void *sqlite3_errmsg16(sqlite3 *db){
  1210 const void *sqlite3_errmsg16(sqlite3 *db){
  1211   /* Because all the characters in the string are in the unicode
  1211   static const u16 outOfMem[] = {
  1212   ** range 0x00-0xFF, if we pad the big-endian string with a 
  1212     'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
  1213   ** zero byte, we can obtain the little-endian string with
       
  1214   ** &big_endian[1].
       
  1215   */
       
  1216   static const char outOfMemBe[] = {
       
  1217     0, 'o', 0, 'u', 0, 't', 0, ' ', 
       
  1218     0, 'o', 0, 'f', 0, ' ', 
       
  1219     0, 'm', 0, 'e', 0, 'm', 0, 'o', 0, 'r', 0, 'y', 0, 0, 0
       
  1220   };
  1213   };
  1221   static const char misuseBe [] = {
  1214   static const u16 misuse[] = {
  1222     0, 'l', 0, 'i', 0, 'b', 0, 'r', 0, 'a', 0, 'r', 0, 'y', 0, ' ', 
  1215     'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
  1223     0, 'r', 0, 'o', 0, 'u', 0, 't', 0, 'i', 0, 'n', 0, 'e', 0, ' ', 
  1216     'r', 'o', 'u', 't', 'i', 'n', 'e', ' ',
  1224     0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, 'e', 0, 'd', 0, ' ', 
  1217     'c', 'a', 'l', 'l', 'e', 'd', ' ',
  1225     0, 'o', 0, 'u', 0, 't', 0, ' ', 
  1218     'o', 'u', 't', ' ',
  1226     0, 'o', 0, 'f', 0, ' ', 
  1219     'o', 'f', ' ',
  1227     0, 's', 0, 'e', 0, 'q', 0, 'u', 0, 'e', 0, 'n', 0, 'c', 0, 'e', 0, 0, 0
  1220     's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
  1228   };
  1221   };
  1229 
  1222 
  1230   const void *z;
  1223   const void *z;
  1231   if( !db ){
  1224   if( !db ){
  1232     return (void *)(&outOfMemBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
  1225     return (void *)outOfMem;
  1233   }
  1226   }
  1234   if( !sqlite3SafetyCheckSickOrOk(db) ){
  1227   if( !sqlite3SafetyCheckSickOrOk(db) ){
  1235     return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
  1228     return (void *)misuse;
  1236   }
  1229   }
  1237   sqlite3_mutex_enter(db->mutex);
  1230   sqlite3_mutex_enter(db->mutex);
  1238   assert( !db->mallocFailed );
  1231   assert( !db->mallocFailed );
  1239   z = sqlite3_value_text16(db->pErr);
  1232   z = sqlite3_value_text16(db->pErr);
  1240   if( z==0 ){
  1233   if( z==0 ){