{
GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? vb.gui.adjust_h : vb.gui.adjust_v;
- int direction = (arg->i & (1 << 2)) ? 1 : -1;
+ int direction = (arg->i & (1 << 2)) ? 1 : -1;
/* type scroll */
if (arg->i & VB_SCROLL_TYPE_SCROLL) {
gboolean command_set(const Arg *arg)
{
gboolean success;
- char *line = NULL;
- char *param;
+ char *param = NULL, *line = NULL;
if (!arg->s || !strlen(arg->s)) {
return FALSE;
static GList *completion_init_completion(GList *target, GList *source,
Comp_Func func, const char *input, const char *prefix)
{
- char *command = NULL;
- char *data = NULL;
+ char *command = NULL, *data = NULL, **token = NULL;
gboolean match;
- char **token = NULL;
/* remove counts before command and save it to print it later in inputbox */
vb.comps.count = g_ascii_strtoll(input, &command, 10);
gboolean dom_is_editable(Element *element)
{
gboolean result = FALSE;
+ char *tagname, *type;
+
if (!element) {
return result;
}
- char *tagname = webkit_dom_element_get_tag_name(element);
- char *type = webkit_dom_element_get_attribute(element, "type");
+ tagname = webkit_dom_element_get_tag_name(element);
+ type = webkit_dom_element_get_attribute(element, "type");
if (!g_ascii_strcasecmp(tagname, "textarea")) {
result = TRUE;
} else if (!g_ascii_strcasecmp(tagname, "input")
void hints_clear()
{
+ char *js, *value = NULL;
+
hints_observe_input(FALSE);
if (CLEAN_MODE(vb.state.mode) == VB_MODE_HINTING) {
- char *js = g_strdup_printf("%s.clear();", HINT_VAR);
- char *value = NULL;
+ js = g_strdup_printf("%s.clear();", HINT_VAR);
vb_eval_script(webkit_web_view_get_main_frame(vb.gui.webview), js, HINT_FILE, &value);
g_free(value);
g_free(js);
*/
void history_cleanup(void)
{
+ const char *file;
for (HistoryType i = HISTORY_FIRST; i < HISTORY_LAST; i++) {
- const char *file = history_get_file_by_type(i);
+ file = history_get_file_by_type(i);
history_write_to_file(history_load(file), file);
}
}
*/
void history_add(HistoryType type, const char *value)
{
- const char *file = history_get_file_by_type(type);
FILE *f;
+ const char *file = history_get_file_by_type(type);
+
if ((f = fopen(file, "a+"))) {
file_lock_set(fileno(f), F_WRLCK);
gboolean keybind_add_from_string(char *keys, const char *command, const Mode mode)
{
+ char **token = NULL;
if (keys == NULL || *keys == '\0') {
return FALSE;
}
/* split the input string into command and parameter part */
- char **token = g_strsplit(command, " ", 2);
+ token = g_strsplit(command, " ", 2);
if (!token[0] || !command_exists(token[0])) {
g_strfreev(token);
return FALSE;
gboolean vb_load_uri(const Arg *arg)
{
- char *uri;
- char *path = arg->s;
+ char *uri, *rp, *path = arg->s;
struct stat st;
if (!path) {
/* check if the path is a file path */
if (stat(path, &st) == 0) {
- char *rp = realpath(path, NULL);
+ rp = realpath(path, NULL);
uri = g_strdup_printf("file://%s", rp);
} else if (!strchr(path, '.')) {
- char *part = NULL;
- char *tmpl = NULL;
- char *query = NULL;
+ char *part = NULL, *tmpl = NULL, *query = NULL;
/* look up for a searchengine with handle */
if ((part = strchr(path, ' '))) {
if (arg->i == VB_TARGET_NEW) {
guint i = 0;
- char *cmd[5];
- char xid[64];
+ char *cmd[5], xid[64];
cmd[i++] = *args;
if (vb.embed) {
void vb_update_statusbar()
{
+ int max, val, num;
GString *status = g_string_new("");
/* show current count */
/* show the active downloads */
if (vb.state.downloads) {
- int num = g_list_length(vb.state.downloads);
+ num = g_list_length(vb.state.downloads);
g_string_append_printf(status, " %d %s", num, num == 1 ? "download" : "downloads");
}
}
/* show the scroll status */
- int max = gtk_adjustment_get_upper(vb.gui.adjust_v) - gtk_adjustment_get_page_size(vb.gui.adjust_v);
- int val = (int)(gtk_adjustment_get_value(vb.gui.adjust_v) / max * 100);
+ max = gtk_adjustment_get_upper(vb.gui.adjust_v) - gtk_adjustment_get_page_size(vb.gui.adjust_v);
+ val = (int)(gtk_adjustment_get_value(vb.gui.adjust_v) / max * 100);
if (max == 0) {
g_string_append(status, " All");
static void vb_gotheaders_cb(SoupMessage *message)
{
- GSList *list = NULL;
- GSList *p = NULL;
+ GSList *list = NULL, *p = NULL;
for(p = list = soup_cookies_from_response(message); p; p = g_slist_next(p)) {
vb_set_cookie((SoupCookie*)p->data);
static gboolean vb_process_input(const char *input)
{
gboolean success;
- char *command = NULL;
- char **token;
+ char *command = NULL, **token;
if (!input || !strlen(input)) {
return FALSE;
static void vb_run_user_script(WebKitWebFrame *frame)
{
- char *js = NULL;
+ char *js = NULL, *value = NULL;
GError *error = NULL;
if (g_file_test(vb.files[FILES_SCRIPT], G_FILE_TEST_IS_REGULAR)
&& g_file_get_contents(vb.files[FILES_SCRIPT], &js, NULL, &error)
) {
- char *value = NULL;
gboolean success = vb_eval_script(frame, js, vb.files[FILES_SCRIPT], &value);
if (!success) {
fprintf(stderr, "%s", value);
static void vb_read_config(void)
{
+ char *line, **lines;
+
/* load default config */
for (guint i = 0; default_config[i].command != NULL; i++) {
if (!vb_process_input(default_config[i].command)) {
}
/* read config from config files */
- char **lines = util_get_lines(vb.files[FILES_CONFIG]);
- char *line;
+ lines = util_get_lines(vb.files[FILES_CONFIG]);
if (lines) {
int length = g_strv_length(lines) - 1;
static void vb_hover_link_cb(WebKitWebView *webview, const char *title, const char *link)
{
+ char *message;
if (link) {
- char *message = g_strdup_printf("Link: %s", link);
+ message = g_strdup_printf("Link: %s", link);
gtk_label_set_text(GTK_LABEL(vb.gui.statusbar.left), message);
g_free(message);
} else {
int main(int argc, char *argv[])
{
static char *winid = NULL;
- static gboolean ver = false;
- static gboolean dump = false;
+ static gboolean ver = false, dump = false;
static GError *err;
static GOptionEntry opts[] = {
{"version", 'v', 0, G_OPTION_ARG_NONE, &ver, "Print version", NULL},
gboolean setting_run(char *name, const char *param)
{
- Arg *a = NULL;
- gboolean result = FALSE;
- gboolean get = FALSE;
+ Arg *a = NULL;
+ gboolean result = FALSE, get = FALSE;
SettingType type = SETTING_SET;
/* determine the type to names last char and param */
static gboolean setting_ca_bundle(const Setting *s, const SettingType type)
{
+ char *value;
if (type == SETTING_GET) {
- char *value = NULL;
g_object_get(vb.soup_session, "ssl-ca-file", &value, NULL);
setting_print_value(s, value);
g_free(value);
static gboolean setting_proxy(const Setting *s, const SettingType type)
{
gboolean enabled;
+ char *proxy, *proxy_new;
SoupURI *proxy_uri = NULL;
/* get the current status */
}
if (enabled) {
- char *proxy = (char *)g_getenv("http_proxy");
+ proxy = (char *)g_getenv("http_proxy");
if (proxy != NULL && strlen(proxy)) {
- char *proxy_new = g_strrstr(proxy, "http://")
+ proxy_new = g_strrstr(proxy, "http://")
? g_strdup(proxy)
: g_strdup_printf("http://%s", proxy);
proxy_uri = soup_uri_new(proxy_new);
char *util_strcasestr(const char *haystack, const char *needle)
{
+ unsigned char c1, c2;
+ int i, j;
int nlen = strlen(needle);
int hlen = strlen(haystack) - nlen + 1;
- int i;
for (i = 0; i < hlen; i++) {
- int j;
for (j = 0; j < nlen; j++) {
- unsigned char c1 = haystack[i + j];
- unsigned char c2 = needle[j];
+ c1 = haystack[i + j];
+ c2 = needle[j];
if (toupper(c1) != toupper(c2)) {
goto next;
}