~ubuntu-branches/ubuntu/wily/weechat/wily

« back to all changes in this revision

Viewing changes to src/core/wee-eval.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2014-02-13 12:11:54 UTC
  • mfrom: (29.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140213121154-k6sdmtnralvjbmgq
Tags: 0.4.3-2
* Add missing symlink for Polish manpage
* Change ruby-* Build-Depends to gem2deb so that ruby plugin will be
  built against the newest Ruby interpreter available (Closes: #738685)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * wee-eval.c - evaluate expressions with references to internal vars
3
3
 *
4
 
 * Copyright (C) 2012-2013 Sebastien Helleu <flashcode@flashtux.org>
 
4
 * Copyright (C) 2012-2014 Sébastien Helleu <flashcode@flashtux.org>
5
5
 *
6
6
 * This file is part of WeeChat, the extensible chat client.
7
7
 *
129
129
            value = strdup (str_value);
130
130
            break;
131
131
        case WEECHAT_HDATA_STRING:
 
132
        case WEECHAT_HDATA_SHARED_STRING:
132
133
            ptr_value = hdata_string (hdata, pointer, var_name);
133
134
            value = (ptr_value) ? strdup (ptr_value) : NULL;
134
135
            break;
235
236
    struct t_config_option *ptr_option;
236
237
    struct t_gui_buffer *ptr_buffer;
237
238
    char str_value[64], *value, *pos, *pos1, *pos2, *hdata_name, *list_name;
238
 
    char *tmp;
239
 
    const char *ptr_value;
 
239
    char *tmp, *info_name;
 
240
    const char *ptr_value, *ptr_arguments;
240
241
    struct t_hdata *hdata;
241
242
    void *pointer;
242
243
 
258
259
        return strdup ((ptr_value) ? ptr_value : "");
259
260
    }
260
261
 
261
 
    /* 3. look for name of option: if found, return this value */
 
262
    /* 3. look for an info */
 
263
    if (strncmp (text, "info:", 5) == 0)
 
264
    {
 
265
        ptr_value = NULL;
 
266
        ptr_arguments = strchr (text + 5, ',');
 
267
        if (ptr_arguments)
 
268
        {
 
269
            info_name = string_strndup (text + 5, ptr_arguments - text - 5);
 
270
            ptr_arguments++;
 
271
        }
 
272
        else
 
273
            info_name = strdup (text + 5);
 
274
        if (info_name)
 
275
        {
 
276
            ptr_value = hook_info_get (NULL, info_name, ptr_arguments);
 
277
            free (info_name);
 
278
        }
 
279
        return strdup ((ptr_value) ? ptr_value : "");
 
280
    }
 
281
 
 
282
    /* 4. look for name of option: if found, return this value */
262
283
    if (strncmp (text, "sec.data.", 9) == 0)
263
284
    {
264
285
        ptr_value = hashtable_get (secure_hashtable_data, text + 9);
269
290
        config_file_search_with_string (text, NULL, NULL, &ptr_option, NULL);
270
291
        if (ptr_option)
271
292
        {
 
293
            if (!ptr_option->value)
 
294
                return strdup ("");
272
295
            switch (ptr_option->type)
273
296
            {
274
297
                case CONFIG_OPTION_TYPE_BOOLEAN:
284
307
                case CONFIG_OPTION_TYPE_COLOR:
285
308
                    return strdup (gui_color_get_name (CONFIG_COLOR(ptr_option)));
286
309
                case CONFIG_NUM_OPTION_TYPES:
287
 
                    return NULL;
 
310
                    return strdup ("");
288
311
            }
289
312
        }
290
313
    }
291
314
 
292
 
    /* 4. look for local variable in buffer */
 
315
    /* 5. look for local variable in buffer */
293
316
    ptr_buffer = hashtable_get (pointers, "buffer");
294
317
    if (ptr_buffer)
295
318
    {
298
321
            return strdup (ptr_value);
299
322
    }
300
323
 
301
 
    /* 5. look for hdata */
 
324
    /* 6. look for hdata */
302
325
    value = NULL;
303
326
    hdata_name = NULL;
304
327
    list_name = NULL;
413
436
            goto end;
414
437
        }
415
438
        rc = (regexec (&regex, expr1, 0, NULL, 0) == 0) ? 1 : 0;
 
439
        regfree (&regex);
416
440
        if (comparison == EVAL_COMPARE_REGEX_NOT_MATCHING)
417
441
            rc ^= 1;
418
442
        goto end;