diff --git a/src/ecmascript/spidermonkey.c b/src/ecmascript/spidermonkey.c index ee109639b..2805c68ff 100644 --- a/src/ecmascript/spidermonkey.c +++ b/src/ecmascript/spidermonkey.c @@ -154,6 +154,7 @@ error_reporter(JSContext *ctx, JSErrorReport *report) struct terminal *term; char *strict, *exception, *warning, *error; struct string msg; + char str_lineno[256]=""; char *prefix = nullptr; @@ -184,7 +185,6 @@ error_reporter(JSContext *ctx, JSErrorReport *report) /* Sometimes the line number is zero */ add_to_string(&msg, "\n\n"); add_to_string(&msg, report->message().c_str()); - char str_lineno[256]=""; sprintf(str_lineno,"\n at line: %d",report->lineno); add_to_string(&msg, str_lineno); diff --git a/src/ecmascript/spidermonkey/localstorage-db.c b/src/ecmascript/spidermonkey/localstorage-db.c index 775e95ba5..71e35945a 100644 --- a/src/ecmascript/spidermonkey/localstorage-db.c +++ b/src/ecmascript/spidermonkey/localstorage-db.c @@ -12,7 +12,7 @@ #include "elinks.h" #include "src/ecmascript/ecmascript.h" -extern const int +int db_prepare_structure(char *db_name) { sqlite3_stmt *stmt; @@ -35,7 +35,7 @@ db_prepare_structure(char *db_name) return(0); } -extern const int +int db_delete_from(char *db_name, char *key) { @@ -64,7 +64,7 @@ db_delete_from(char *db_name, char *key) } -extern const int +int db_insert_into(char *db_name, char *key, char *value) { sqlite3_stmt *stmt; @@ -91,7 +91,7 @@ db_insert_into(char *db_name, char *key, char *value) } -extern const int +int db_update_set(char *db_name, char *key, char *value) { @@ -119,7 +119,7 @@ db_update_set(char *db_name, char *key, char *value) } -extern const char * +char * db_query_by_value(char *db_name, char *value) { @@ -134,14 +134,16 @@ db_query_by_value(char *db_name, char *value) { //DBG("Error opening localStorage database."); rc=sqlite3_close(db); - return(""); + return stracpy(""); } sqlite3_busy_timeout(db, 2000); rc=sqlite3_prepare_v2(db, "SELECT key FROM storage WHERE value = ? LIMIT 1;", -1, &stmt, NULL); rc=sqlite3_bind_text(stmt, 1, value, strlen(value), SQLITE_STATIC); - result=stracpy(""); + if ((const char*) sqlite3_column_text(stmt,1)!= NULL) { result=stracpy((const char *)sqlite3_column_text(stmt, 1)); + } else { + result=stracpy(""); } rc=sqlite3_finalize(stmt); rc=sqlite3_close(db); @@ -149,7 +151,7 @@ db_query_by_value(char *db_name, char *value) } -extern const char * +char * db_query_by_key(char *db_name, char *key) { @@ -164,15 +166,16 @@ db_query_by_key(char *db_name, char *key) { //DBG("Error opening localStorage database."); rc=sqlite3_close(db); - return(""); + return stracpy(""); } sqlite3_busy_timeout(db, 2000); rc=sqlite3_prepare_v2(db, "SELECT * FROM storage WHERE key = ? LIMIT 1;", -1, &stmt, NULL); rc=sqlite3_bind_text(stmt, 1, key, strlen(key), SQLITE_STATIC); - result=stracpy(""); rc=sqlite3_step(stmt); if ((const char*) sqlite3_column_text(stmt,1)!= NULL) { result=stracpy((const unsigned char *)sqlite3_column_text(stmt, 1)); + } else { + result = stracpy(""); } rc=sqlite3_finalize(stmt); rc=sqlite3_close(db); diff --git a/src/ecmascript/spidermonkey/localstorage-db.h b/src/ecmascript/spidermonkey/localstorage-db.h index 6de343a65..b290104f8 100644 --- a/src/ecmascript/spidermonkey/localstorage-db.h +++ b/src/ecmascript/spidermonkey/localstorage-db.h @@ -6,11 +6,11 @@ #include #include -extern const int db_prepare_structure(char *db_name); -extern const int db_delete_from(char *db_name, char *key); -extern const int db_insert_into(char *db_name, char *key, char *value); -extern const int db_update_set(char *db_name, char *key, char *value); -extern const char * db_query_by_key(char *db_name, char *key); -extern const char * db_qry_by_value(char *db_name, char *val); +int db_prepare_structure(char *db_name); +int db_delete_from(char *db_name, char *key); +int db_insert_into(char *db_name, char *key, char *value); +int db_update_set(char *db_name, char *key, char *value); +char * db_query_by_key(char *db_name, char *key); +char * db_qry_by_value(char *db_name, char *val); #endif