Changeset 1c01cdf7


Ignore:
Timestamp:
Jun 25, 2011, 2:29:50 AM (13 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
8b293ea (diff), 2bc6bb16 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge 2bc6bb1631398bd9cd2eaeee9ed91c2a15649b30 into 8b293ea82bfdae7cddf0e0665ef6eca1cc0df04d
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rd427f08 r1c01cdf7  
    26322632  ptr = skiptokens(buff, 1);
    26332633  hist = owl_global_get_cmd_history(&g);
    2634   owl_history_store(hist, ptr);
    2635   owl_history_reset(hist);
     2634  owl_history_store(hist, ptr, false);
    26362635  /* owl_function_makemsg("History '%s' stored successfully", ptr+1); */
    26372636  return NULL;
     
    26552654
    26562655  hist = owl_global_get_cmd_history(&g);
    2657   owl_history_store(hist, ptr);
    2658   owl_history_reset(hist);
     2656  owl_history_store(hist, ptr, false);
    26592657  return owl_function_command(ptr);
    26602658}
     
    27392737
    27402738  hist = owl_editwin_get_history(e);
    2741   if (hist) {
    2742     owl_history_store(hist, owl_editwin_get_text(e));
    2743     owl_history_reset(hist);
    2744   }
     2739  if (hist)
     2740    owl_history_store(hist, owl_editwin_get_text(e), false);
    27452741
    27462742  owl_global_pop_context(&g);
     
    27552751  if (!hist)
    27562752    return;
    2757   if (!owl_history_is_touched(hist)) {
    2758     owl_history_store(hist, owl_editwin_get_text(e));
    2759     owl_history_set_partial(hist);
    2760   }
     2753  if (!owl_history_is_touched(hist))
     2754    owl_history_store(hist, owl_editwin_get_text(e), true);
    27612755  ptr=owl_history_get_prev(hist);
    27622756  if (ptr) {
     
    27962790  owl_history *hist=owl_editwin_get_history(e);
    27972791
    2798   if (hist) {
    2799     owl_history_store(hist, owl_editwin_get_text(e));
    2800     owl_history_reset(hist);
    2801   }
     2792  if (hist)
     2793    owl_history_store(hist, owl_editwin_get_text(e), false);
    28022794
    28032795  /* Take a reference to the editwin, so that it survives the pop
  • functions.c

    r8b293ea r1c01cdf7  
    18411841    if (enter) {
    18421842      owl_history *hist = owl_global_get_cmd_history(&g);
    1843       owl_history_store(hist, buff);
    1844       owl_history_reset(hist);
     1843      owl_history_store(hist, buff, false);
    18451844      owl_function_command_norv(buff);
    18461845    } else {
  • global.c

    rd427f08 r1c01cdf7  
    6565  owl_history_init(&(g->msghist));
    6666  owl_history_init(&(g->cmdhist));
    67   owl_history_set_norepeats(&(g->cmdhist));
    6867  g->nextmsgid=0;
    6968
  • history.c

    rd4927a7 r2bc6bb16  
    33void owl_history_init(owl_history *h)
    44{
    5   owl_list_create(&(h->hist));
    6   h->cur=0;                     /* current position in history */
    7   h->touched=0;                 /* whether we've gone into history */
    8   h->partial=0;                 /* is the 0th element is partially composed? */
    9   h->repeats=1;                 /* by default we'll allow repeat entries */
    10 }
    11 
    12 void owl_history_set_norepeats(owl_history *h)
    13 {
    14   h->repeats=0;
     5  g_queue_init(&h->hist);
     6  h->cur = h->hist.tail;        /* current position in history */
     7  h->partial = false;           /* is the 0th element is partially composed? */
    158}
    169
    1710const char *owl_history_get_prev(owl_history *h)
    1811{
     12  if (!h) return NULL;
    1913
    20   if (!h) return NULL;
    21   h->touched=1;
     14  if (h->cur == NULL || g_list_previous(h->cur) == NULL) return NULL;
    2215
    23   if (owl_list_get_size(&(h->hist))==0) return(NULL);
    24 
    25   if (h->cur == owl_list_get_size(&(h->hist))-1) {
    26     return(NULL);
    27   }
    28 
    29   h->cur++;
    30 
    31   return(owl_list_get_element(&(h->hist), h->cur));
     16  h->cur = g_list_previous(h->cur);
     17  return h->cur->data;
    3218}
    3319
     
    3521{
    3622  if (!h) return NULL;
    37   if (owl_list_get_size(&(h->hist))==0) return(NULL);
    38   if (h->cur==0) {
    39     return(NULL);
    40   }
    4123
    42   h->cur--;
    43   return(owl_list_get_element(&(h->hist), h->cur));
     24  if (h->cur == NULL || g_list_next(h->cur) == NULL) return NULL;
     25
     26  h->cur = g_list_next(h->cur);
     27  return h->cur->data;
    4428}
    4529
    46 void owl_history_store(owl_history *h, const char *line)
     30void owl_history_store(owl_history *h, const char *line, bool partial)
    4731{
    48   int size;
     32  if (!h) return;
    4933
    50   if (!h) return;
    51   size=owl_list_get_size(&(h->hist));
     34  owl_history_reset(h);
    5235
    53   /* if partial is set, remove the first entry first */
    54   if (h->partial) {
    55     g_free(owl_list_get_element(&(h->hist), 0));
    56     owl_list_remove_element(&(h->hist), 0);
    57   }
    58 
    59   /* if repeats are disallowed, check if the line is the same as the last */
    60   if (owl_list_get_size(&(h->hist))>0) {
    61     if (!strcmp(line, owl_list_get_element(&(h->hist), 0))) return;
    62   }
     36  /* check if the line is the same as the last */
     37  if (!partial && !g_queue_is_empty(&h->hist) &&
     38      strcmp(line, g_queue_peek_tail(&h->hist)) == 0)
     39    return;
    6340
    6441  /* if we've reached the max history size, pop off the last element */
    65   if (size>OWL_HISTORYSIZE) {
    66     g_free(owl_list_get_element(&(h->hist), size-1));
    67     owl_list_remove_element(&(h->hist), size-1);
    68   }
     42  if (g_queue_get_length(&h->hist) > OWL_HISTORYSIZE)
     43    g_free(g_queue_pop_head(&h->hist));
    6944
    7045  /* add the new line */
    71   owl_list_prepend_element(&(h->hist), g_strdup(line));
    72 }
    73 
    74 void owl_history_set_partial(owl_history *h)
    75 {
    76   if (!h) return;
    77   h->partial=1;
     46  g_queue_push_tail(&h->hist, g_strdup(line));
     47  h->partial = partial;
     48  h->cur = h->hist.tail;
    7849}
    7950
     
    8152{
    8253  if (!h) return;
    83   h->cur=0;
    84   h->touched=0;
    85   h->partial=0;
     54
     55  /* if partial is set, remove the first entry first */
     56  if (h->partial) {
     57    g_free(g_queue_pop_tail(&h->hist));
     58    h->partial = false;
     59  }
     60
     61  h->cur = h->hist.tail;
    8662}
    8763
     
    8965{
    9066  if (!h) return(0);
    91   if (h->touched) return(1);
    92   return(0);
     67  return h->cur != NULL && g_list_next(h->cur) != NULL;
    9368}
  • owl.h

    rd427f08 r1c01cdf7  
    455455
    456456typedef struct _owl_history {
    457   owl_list hist;
    458   int cur;
    459   int touched;
    460   int partial;
    461   int repeats;
     457  GQueue hist;
     458  GList *cur;
     459  bool partial;
    462460} owl_history;
    463461
  • aim.c

    r6b0b4f4 rd427f08  
    437437
    438438/* caller must free the return */
    439 char *owl_aim_normalize_screenname(const char *in)
     439G_GNUC_WARN_UNUSED_RESULT char *owl_aim_normalize_screenname(const char *in)
    440440{
    441441  char *out;
  • cmd.c

    raad166a rd427f08  
    99/**************************************************************************/
    1010
    11 int owl_cmddict_setup(owl_cmddict *cd) {
     11void owl_cmddict_setup(owl_cmddict *cd)
     12{
    1213  owl_cmddict_init(cd);
    13   return owl_cmd_add_defaults(cd);
     14  owl_cmd_add_defaults(cd);
    1415}
    1516
     
    1920
    2021/* for bulk initialization at startup */
    21 int owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds) {
     22void owl_cmddict_add_from_list(owl_cmddict *cd, const owl_cmd *cmds)
     23{
    2224  const owl_cmd *cur;
    23   int ret = 0;
    2425  for (cur = cmds; cur->name != NULL; cur++) {
    25     ret = owl_cmddict_add_cmd(cd, cur);
    26     if (ret < 0) break;
    27   }
    28   return ret;
     26    owl_cmddict_add_cmd(cd, cur);
     27  }
    2928}
    3029
     
    3837
    3938/* creates a new command alias */
    40 int owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
     39void owl_cmddict_add_alias(owl_cmddict *cd, const char *alias_from, const char *alias_to) {
    4140  owl_cmd *cmd;
    4241  cmd = g_new(owl_cmd, 1);
     
    4443  owl_perlconfig_new_command(cmd->name);
    4544  owl_dict_insert_element(cd, cmd->name, cmd, (void (*)(void *))owl_cmd_delete);
    46   return(0);
    4745}
    4846
     
    5755}
    5856
    59 char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff) {
     57/* caller must free the return */
     58G_GNUC_WARN_UNUSED_RESULT char *_owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc, const char *buff)
     59{
    6060  char *retval = NULL;
    6161  const owl_cmd *cmd;
     
    7272}
    7373
    74 char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff) {
     74/* caller must free the return */
     75G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute(const owl_cmddict *cd, const owl_context *ctx, const char *cmdbuff)
     76{
    7577  char **argv;
    7678  int argc;
     
    9496}
    9597
    96 char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc) {
     98/* caller must free the return */
     99G_GNUC_WARN_UNUSED_RESULT char *owl_cmddict_execute_argv(const owl_cmddict *cd, const owl_context *ctx, const char *const *argv, int argc)
     100{
    97101  char *buff;
    98102  char *retval = NULL;
     
    121125}
    122126
    123 int owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
     127void owl_cmd_create_alias(owl_cmd *cmd, const char *name, const char *aliased_to) {
    124128  memset(cmd, 0, sizeof(owl_cmd));
    125129  cmd->name = g_strdup(name);
    126130  cmd->cmd_aliased_to = g_strdup(aliased_to);
    127131  cmd->summary = g_strdup_printf("%s%s", OWL_CMD_ALIAS_SUMMARY_PREFIX, aliased_to);
    128   return(0);
    129132}
    130133
     
    150153}
    151154
    152 char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff) {
     155/* caller must free the result */
     156G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_execute(const owl_cmd *cmd, const owl_cmddict *cd, const owl_context *ctx, int argc, const char *const *argv, const char *cmdbuff)
     157{
    153158  static int alias_recurse_depth = 0;
    154159  int ival=0;
     
    223228
    224229/* returns a summary line describing this keymap.  the caller must free. */
    225 char *owl_cmd_describe(const owl_cmd *cmd) {
     230G_GNUC_WARN_UNUSED_RESULT char *owl_cmd_describe(const owl_cmd *cmd)
     231{
    226232  if (!cmd || !cmd->name || !cmd->summary) return NULL;
    227233  return g_strdup_printf("%-25s - %s", cmd->name, cmd->summary);
  • context.c

    rd4927a7 rd427f08  
    66
    77/* TODO: dependency from owl_context -> owl_window is annoying. */
    8 owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
     8G_GNUC_WARN_UNUSED_RESULT owl_context *owl_context_new(int mode, void *data, const char *keymap, owl_window *cursor)
    99{
    1010  owl_context *c;
  • dict.c

    r4c7c21f rd427f08  
    107107/* Doesn't free the value of the element, but does
    108108 * return it so the caller can free it. */
    109 void *owl_dict_remove_element(owl_dict *d, const char *k) {
     109G_GNUC_WARN_UNUSED_RESULT void *owl_dict_remove_element(owl_dict *d, const char *k)
     110{
    110111  int i;
    111112  int pos, found;
  • editcontext.c

    r4a41f16 rd427f08  
    88}
    99
    10 owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
     10G_GNUC_WARN_UNUSED_RESULT owl_context *owl_editcontext_new(int mode, owl_editwin *e, const char *keymap, void (*deactivate_cb)(owl_context*), void *cbdata)
    1111{
    1212  owl_context *ctx = owl_context_new(mode, owl_editwin_ref(e), keymap,
  • editwin.c

    r3b8a563 rd427f08  
    6161static const char *oe_copy_buf(owl_editwin *e, const char *buf, int len);
    6262static int oe_copy_region(owl_editwin *e);
    63 static char *oe_chunk(owl_editwin *e, int start, int end);
     63static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end);
    6464static void oe_destroy_cbdata(owl_editwin *e);
    6565static void oe_dirty(owl_editwin *e);
     
    7070#define WHITESPACE " \n\t"
    7171
    72 static owl_editwin *owl_editwin_allocate(void)
     72static G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_allocate(void)
    7373{
    7474  owl_editwin *e = g_new0(owl_editwin, 1);
     
    142142}
    143143
    144 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
     144G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist)
    145145{
    146146  owl_editwin *e = owl_editwin_allocate();
     
    13691369}
    13701370
    1371 char *owl_editwin_get_region(owl_editwin *e)
     1371G_GNUC_WARN_UNUSED_RESULT char *owl_editwin_get_region(owl_editwin *e)
    13721372{
    13731373  int start, end;
     
    13881388}
    13891389
    1390 static char *oe_chunk(owl_editwin *e, int start, int end)
     1390static G_GNUC_WARN_UNUSED_RESULT char *oe_chunk(owl_editwin *e, int start, int end)
    13911391{
    13921392  char *p;
  • filter.c

    re56303f rd427f08  
    200200
    201201
    202 char* owl_filter_print(const owl_filter *f)
     202char G_GNUC_WARN_UNUSED_RESULT *owl_filter_print(const owl_filter *f)
    203203{
    204204  GString *out = g_string_new("");
  • fmtext.c

    r7b4f3be rd427f08  
    171171 * freeing the return
    172172 */
    173 char *owl_fmtext_print_plain(const owl_fmtext *f)
     173char G_GNUC_WARN_UNUSED_RESULT *owl_fmtext_print_plain(const owl_fmtext *f)
    174174{
    175175  return owl_strip_format_chars(f->buff->str);
  • keybinding.c

    r3b8a563 rd427f08  
    1414
    1515/* sets up a new keybinding for a command */
    16 owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
     16G_GNUC_WARN_UNUSED_RESULT owl_keybinding *owl_keybinding_new(const char *keyseq, const char *command, void (*function_fn)(void), const char *desc)
    1717{
    1818  owl_keybinding *kb = g_new(owl_keybinding, 1);
     
    8585}
    8686
    87 char *owl_keybinding_stack_tostring(int *j, int len)
     87G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_stack_tostring(int *j, int len)
    8888{
    8989  GString *string;
     
    100100}
    101101
    102 char *owl_keybinding_tostring(const owl_keybinding *kb)
     102G_GNUC_WARN_UNUSED_RESULT char *owl_keybinding_tostring(const owl_keybinding *kb)
    103103{
    104104  return owl_keybinding_stack_tostring(kb->keys, kb->len);
  • keymap.c

    r4c7c21f rd427f08  
    5151    }
    5252  }
    53   return owl_list_append_element(&km->bindings, kb); 
    54 
     53  owl_list_append_element(&km->bindings, kb);
     54  return 0;
    5555}
    5656
     
    8080
    8181/* returns a summary line describing this keymap.  the caller must free. */
    82 char *owl_keymap_summary(const owl_keymap *km)
     82G_GNUC_WARN_UNUSED_RESULT char *owl_keymap_summary(const owl_keymap *km)
    8383{
    8484  if (!km || !km->name || !km->desc) return NULL;
  • keypress.c

    rd07af84 rd427f08  
    129129/* OWL_META is definied in owl.h */
    130130
    131 char *owl_keypress_tostring(int j, int esc)
     131char G_GNUC_WARN_UNUSED_RESULT *owl_keypress_tostring(int j, int esc)
    132132{
    133133  GString *kb;
  • list.c

    rfda61d3 rd427f08  
    5353}
    5454
    55 int owl_list_append_element(owl_list *l, void *element)
     55void owl_list_append_element(owl_list *l, void *element)
    5656{
    57   return owl_list_insert_element(l, l->size, element);
     57  owl_list_insert_element(l, l->size, element);
    5858}
    5959
    60 int owl_list_prepend_element(owl_list *l, void *element)
     60void owl_list_prepend_element(owl_list *l, void *element)
    6161{
    62   return owl_list_insert_element(l, 0, element);
     62  owl_list_insert_element(l, 0, element);
    6363}
    6464
  • logging.c

    rcc305b5 rd427f08  
    8080}
    8181
    82 char *owl_log_zephyr(const owl_message *m) {
     82G_GNUC_WARN_UNUSED_RESULT char *owl_log_zephyr(const owl_message *m)
     83{
    8384    char *tmp = NULL;
    8485    GString *buffer = NULL;
     
    103104}
    104105
    105 char *owl_log_aim(const owl_message *m) {
     106G_GNUC_WARN_UNUSED_RESULT char *owl_log_aim(const owl_message *m)
     107{
    106108    GString *buffer = NULL;
    107109    buffer = g_string_new("");
     
    120122}
    121123
    122 char *owl_log_jabber(const owl_message *m) {
     124G_GNUC_WARN_UNUSED_RESULT char *owl_log_jabber(const owl_message *m)
     125{
    123126    GString *buffer = NULL;
    124127    buffer = g_string_new("");
     
    132135}
    133136
    134 char *owl_log_generic(const owl_message *m) {
     137G_GNUC_WARN_UNUSED_RESULT char *owl_log_generic(const owl_message *m)
     138{
    135139    GString *buffer;
    136140    buffer = g_string_new("");
  • message.c

    r259e60a8 rd427f08  
    580580
    581581/* caller must free return value. */
    582 char *owl_message_get_cc(const owl_message *m)
     582G_GNUC_WARN_UNUSED_RESULT char *owl_message_get_cc(const owl_message *m)
    583583{
    584584  const char *cur;
     
    597597
    598598/* caller must free return value */
    599 GList *owl_message_get_cc_without_recipient(const owl_message *m)
     599G_GNUC_WARN_UNUSED_RESULT GList *owl_message_get_cc_without_recipient(const owl_message *m)
    600600{
    601601  char *cc, *shortuser, *recip;
  • messagelist.c

    r66a8cd6 rd427f08  
    4242}
    4343
    44 int owl_messagelist_append_element(owl_messagelist *ml, void *element)
     44void owl_messagelist_append_element(owl_messagelist *ml, void *element)
    4545{
    46   return(owl_list_append_element(&(ml->list), element));
     46  owl_list_append_element(&ml->list, element);
    4747}
    4848
  • perlconfig.c

    rbcde7926 rd427f08  
    2323
    2424
    25 SV *owl_new_sv(const char * str)
     25G_GNUC_WARN_UNUSED_RESULT SV *owl_new_sv(const char * str)
    2626{
    2727  SV *ret = newSVpv(str, 0);
     
    3636}
    3737
    38 AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
     38G_GNUC_WARN_UNUSED_RESULT AV *owl_new_av(const owl_list *l, SV *(*to_sv)(const void *))
    3939{
    4040  AV *ret;
     
    5252}
    5353
    54 HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
     54G_GNUC_WARN_UNUSED_RESULT HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *))
    5555{
    5656  HV *ret;
     
    7575}
    7676
    77 SV *owl_perlconfig_message2hashref(const owl_message *m)
     77G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_message2hashref(const owl_message *m)
    7878{
    7979  HV *h, *stash;
     
    165165}
    166166
    167 SV *owl_perlconfig_curmessage2hashref(void)
     167G_GNUC_WARN_UNUSED_RESULT SV *owl_perlconfig_curmessage2hashref(void)
    168168{
    169169  int curmsg;
     
    183183   This has been somewhat addressed, but is still not lossless.
    184184 */
    185 owl_message * owl_perlconfig_hashref2message(SV *msg)
     185G_GNUC_WARN_UNUSED_RESULT owl_message *owl_perlconfig_hashref2message(SV *msg)
    186186{
    187187  owl_message * m;
     
    251251/* Calls in a scalar context, passing it a hash reference.
    252252   If return value is non-null, caller must free. */
    253 char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
     253G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_call_with_message(const char *subname, const owl_message *m)
    254254{
    255255  dSP ;
     
    300300   If the return value is non-null, the caller must free it.
    301301 */
    302 char * owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char ** argv)
     302G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_message_call_method(const owl_message *m, const char *method, int argc, const char **argv)
    303303{
    304304  dSP;
     
    349349}
    350350
    351 
    352 char *owl_perlconfig_initperl(const char * file, int *Pargc, char ***Pargv, char *** Penv)
     351/* caller must free result, if not NULL */
     352G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_initperl(const char *file, int *Pargc, char ***Pargv, char ***Penv)
    353353{
    354354  int ret;
     
    436436
    437437/* caller is responsible for freeing returned string */
    438 char *owl_perlconfig_execute(const char *line)
     438G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_execute(const char *line)
    439439{
    440440  STRLEN len;
     
    505505}
    506506
    507 char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
     507/* caller must free the result */
     508G_GNUC_WARN_UNUSED_RESULT char *owl_perlconfig_perlcmd(const owl_cmd *cmd, int argc, const char *const *argv)
    508509{
    509510  int i, count;
  • popwin.c

    rddbbcffa rd427f08  
    11#include "owl.h"
    22
    3 owl_popwin *owl_popwin_new(void)
     3G_GNUC_WARN_UNUSED_RESULT owl_popwin *owl_popwin_new(void)
    44{
    55  owl_popwin *pw = g_new0(owl_popwin, 1);
  • regex.c

    rd4927a7 rd427f08  
    3939{
    4040  char *quoted;
     41  int ret;
    4142 
    42   quoted=owl_text_quote(string, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
    43   owl_regex_create(re, quoted);
     43  quoted = owl_text_quote(string, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH);
     44  ret = owl_regex_create(re, quoted);
    4445  g_free(quoted);
    45   return(0);
     46  return ret;
    4647}
    4748
  • text.c

    r7865479 rd427f08  
    77/* Returns a copy of 'in' with each line indented 'n'
    88 * characters. Result must be freed with g_free. */
    9 char *owl_text_indent(const char *in, int n)
     9G_GNUC_WARN_UNUSED_RESULT char *owl_text_indent(const char *in, int n)
    1010{
    1111  const char *ptr1, *ptr2, *last;
     
    4848
    4949/* caller must free the return */
    50 char *owl_text_htmlstrip(const char *in)
     50G_GNUC_WARN_UNUSED_RESULT char *owl_text_htmlstrip(const char *in)
    5151{
    5252  const char *ptr1, *end, *ptr2, *ptr3;
     
    129129
    130130/* Caller must free return */
    131 char *owl_text_expand_tabs(const char *in)
     131G_GNUC_WARN_UNUSED_RESULT char *owl_text_expand_tabs(const char *in)
    132132{
    133133  int len = 0;
     
    188188
    189189/* caller must free the return */
    190 char *owl_text_wordwrap(const char *in, int col)
     190G_GNUC_WARN_UNUSED_RESULT char *owl_text_wordwrap(const char *in, int col)
    191191{
    192192  char *out;
     
    269269 * Caller must free returned string.
    270270 */
    271 char *owl_text_substitute(const char *in, const char *from, const char *to)
     271G_GNUC_WARN_UNUSED_RESULT char *owl_text_substitute(const char *in, const char *from, const char *to)
    272272{
    273273  char **split = g_strsplit(in, from, 0), *out;
     
    284284 * On success returns the string, on error returns NULL.
    285285 */
    286 char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
     286G_GNUC_WARN_UNUSED_RESULT char *owl_text_quote(const char *in, const char *toquote, const char *quotestr)
    287287{
    288288  int i, x, r, place, escape;
  • util.c

    r83a4af3 rd427f08  
    3535 * duplicate slashes are removed.  Caller must free the return.
    3636 */
    37 char *owl_util_makepath(const char *in)
     37G_GNUC_WARN_UNUSED_RESULT char *owl_util_makepath(const char *in)
    3838{
    3939  int i, j, x;
     
    102102   to -1, argv will be NULL and the caller does not need to free anything. The
    103103   returned vector is NULL-terminated. */
    104 char **owl_parseline(const char *line, int *argc)
     104G_GNUC_WARN_UNUSED_RESULT char **owl_parseline(const char *line, int *argc)
    105105{
    106106  GPtrArray *argv;
     
    245245}
    246246
    247 char *owl_string_build_quoted(const char *tmpl, ...)
     247G_GNUC_WARN_UNUSED_RESULT char *owl_string_build_quoted(const char *tmpl, ...)
    248248{
    249249  GString *buf = g_string_new("");
     
    257257/* Returns a quoted version of arg suitable for placing in a
    258258 * command-line. Result should be freed with g_free. */
    259 char *owl_arg_quote(const char *arg)
     259G_GNUC_WARN_UNUSED_RESULT char *owl_arg_quote(const char *arg)
    260260{
    261261  GString *buf = g_string_new("");;
     
    265265
    266266/* caller must free the return */
    267 char *owl_util_minutes_to_timestr(int in)
     267G_GNUC_WARN_UNUSED_RESULT char *owl_util_minutes_to_timestr(int in)
    268268{
    269269  int days, hours;
     
    331331
    332332/* Get the default tty name.  Caller must free the return */
    333 char *owl_util_get_default_tty(void)
     333G_GNUC_WARN_UNUSED_RESULT char *owl_util_get_default_tty(void)
    334334{
    335335  const char *tmp;
     
    353353 * return.
    354354 */
    355 char *owl_util_stripnewlines(const char *in)
     355G_GNUC_WARN_UNUSED_RESULT char *owl_util_stripnewlines(const char *in)
    356356{
    357357 
     
    384384 * Error conditions are the same as g_file_read_link.
    385385 */
    386 gchar *owl_util_recursive_resolve_link(const char *filename)
     386G_GNUC_WARN_UNUSED_RESULT gchar *owl_util_recursive_resolve_link(const char *filename)
    387387{
    388388  gchar *last_path = g_strdup(filename);
     
    511511   The caller is responsible for freeing the allocated string.
    512512*/
    513 char * owl_util_baseclass(const char * class)
     513G_GNUC_WARN_UNUSED_RESULT char *owl_util_baseclass(const char *class)
    514514{
    515515  char *start, *end;
     
    546546
    547547/* Strips format characters from a valid utf-8 string. Returns the
    548    empty string if 'in' does not validate. */
    549 char * owl_strip_format_chars(const char *in)
     548   empty string if 'in' does not validate.  Caller must free the return. */
     549G_GNUC_WARN_UNUSED_RESULT char *owl_strip_format_chars(const char *in)
    550550{
    551551  char *r;
     
    584584 * out characters in Unicode Plane 16, as we use that plane internally
    585585 * for formatting.
    586  */
    587 char * owl_validate_or_convert(const char *in)
     586 * Caller must free the return.
     587 */
     588G_GNUC_WARN_UNUSED_RESULT char *owl_validate_or_convert(const char *in)
    588589{
    589590  if (g_utf8_validate(in, -1, NULL)) {
     
    599600 * Validate 'in' as UTF-8, and either return a copy of it, or an empty
    600601 * string if it is invalid utf-8.
    601  */
    602 char * owl_validate_utf8(const char *in)
     602 * Caller must free the return.
     603 */
     604G_GNUC_WARN_UNUSED_RESULT char *owl_validate_utf8(const char *in)
    603605{
    604606  char *out;
     
    632634}
    633635
    634 char *owl_escape_highbit(const char *str)
     636/* caller must free the return */
     637G_GNUC_WARN_UNUSED_RESULT char *owl_escape_highbit(const char *str)
    635638{
    636639  GString *out = g_string_new("");
     
    695698
    696699/* Read the rest of the input available in fp into a string. */
    697 char *owl_slurp(FILE *fp)
     700G_GNUC_WARN_UNUSED_RESULT char *owl_slurp(FILE *fp)
    698701{
    699702  char *buf = NULL;
  • variable.c

    r72146c7 rd427f08  
    646646}
    647647
    648 owl_variable * owl_variable_newvar(const char *name, const char *summary, const char * description) {
     648G_GNUC_WARN_UNUSED_RESULT owl_variable *owl_variable_newvar(const char *name, const char *summary, const char *description)
     649{
    649650  owl_variable * var = g_new0(owl_variable, 1);
    650651  var->name = g_strdup(name);
     
    824825}
    825826
    826 char *owl_variable_get_tostring(const owl_vardict *d, const char *name) {
     827G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_tostring(const owl_vardict *d, const char *name)
     828{
    827829  owl_variable *v;
    828830  if (!name) return NULL;
     
    832834}
    833835
    834 char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name) {
     836G_GNUC_WARN_UNUSED_RESULT char *owl_variable_get_default_tostring(const owl_vardict *d, const char *name)
     837{
    835838  owl_variable *v;
    836839  if (!name) return NULL;
     
    992995}
    993996
    994 char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val) {
     997G_GNUC_WARN_UNUSED_RESULT char *owl_variable_bool_get_tostring_default(const owl_variable *v, const void *val)
     998{
    995999  if (val == NULL) {
    9961000    return g_strdup("<null>");
     
    10271031}
    10281032
    1029 char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val) {
     1033G_GNUC_WARN_UNUSED_RESULT char *owl_variable_int_get_tostring_default(const owl_variable *v, const void *val)
     1034{
    10301035  if (val == NULL) {
    10311036    return g_strdup("<null>");
     
    10661071}
    10671072
    1068 char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val) {
     1073G_GNUC_WARN_UNUSED_RESULT char *owl_variable_enum_get_tostring(const owl_variable *v, const void *val)
     1074{
    10691075  char **enums;
    10701076  int nenums, i;
     
    11061112}
    11071113
    1108 char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val) {
     1114G_GNUC_WARN_UNUSED_RESULT char *owl_variable_string_get_tostring_default(const owl_variable *v, const void *val)
     1115{
    11091116  if (val == NULL) {
    11101117    return g_strdup("<null>");
  • viewwin.c

    r4fd211f rd427f08  
    1212 * will be used by the viewwin
    1313 */
    14 owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
     14G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_text(owl_window *win, const char *text)
    1515{
    1616  owl_viewwin *v = g_new0(owl_viewwin, 1);
     
    3434 * will be used by the viewwin
    3535 */
    36 owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
     36G_GNUC_WARN_UNUSED_RESULT owl_viewwin *owl_viewwin_new_fmtext(owl_window *win, const owl_fmtext *fmtext)
    3737{
    3838  char *text;
     
    237237}
    238238
    239 owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
     239G_GNUC_WARN_UNUSED_RESULT owl_editwin *owl_viewwin_set_typwin_active(owl_viewwin *v, owl_history *hist) {
    240240  int lines, cols;
    241241  owl_editwin *cmdline;
  • window.c

    rf97c1a6 rd427f08  
    569569};
    570570
    571 GSource *owl_window_redraw_source_new(void) {
     571G_GNUC_WARN_UNUSED_RESULT GSource *owl_window_redraw_source_new(void)
     572{
    572573  GSource *source;
    573574  source = g_source_new(&redraw_funcs, sizeof(GSource));
  • zcrypt.c

    r5b197f7 rd427f08  
    5353} ZWRITEOPTIONS;
    5454
    55 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
     55G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance);
    5656int ParseCryptSpec(const char *spec, const char **keyfile);
    57 char *BuildArgString(char **argv, int start, int end);
    58 char *read_keystring(const char *keyfile);
     57G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end);
     58G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile);
    5959
    6060int do_encrypt(int zephyr, const char *class, const char *instance,
     
    364364/* Build a space-separated string from argv from elements between start  *
    365365 * and end - 1.  malloc()'s the returned string. */
    366 char *BuildArgString(char **argv, int start, int end)
     366G_GNUC_WARN_UNUSED_RESULT char *BuildArgString(char **argv, int start, int end)
    367367{
    368368  int len = 1;
     
    401401#define MAX_SEARCH 3
    402402/* Find the class/instance in the .crypt-table */
    403 char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
     403G_GNUC_WARN_UNUSED_RESULT char *GetZephyrVarKeyFile(const char *whoami, const char *class, const char *instance)
    404404{
    405405  char *keyfile = NULL;
     
    579579}
    580580
    581 char *slurp_stdin(int ignoredot, int *length) {
     581G_GNUC_WARN_UNUSED_RESULT char *slurp_stdin(int ignoredot, int *length) {
    582582  char *buf;
    583583  char *inptr;
     
    611611}
    612612
    613 char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
     613G_GNUC_WARN_UNUSED_RESULT char *GetInputBuffer(ZWRITEOPTIONS *zoptions, int *length) {
    614614  char *buf;
    615615
     
    637637}
    638638
    639 char *read_keystring(const char *keyfile) {
     639G_GNUC_WARN_UNUSED_RESULT char *read_keystring(const char *keyfile) {
    640640  char *keystring;
    641641  FILE *fkey = fopen(keyfile, "r");
  • zephyr.c

    re146cd7 rd427f08  
    524524 */
    525525#ifdef HAVE_LIBZEPHYR
    526 char *owl_zephyr_get_field(const ZNotice_t *n, int j)
     526G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(const ZNotice_t *n, int j)
    527527{
    528528  int i, count, save;
     
    552552}
    553553
    554 char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
     554G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(const ZNotice_t *n, int j)
    555555{
    556556  int i, count, save;
     
    584584}
    585585#else
    586 char *owl_zephyr_get_field(void *n, int j)
     586G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field(void *n, int j)
    587587{
    588588  return(g_strdup(""));
    589589}
    590 char *owl_zephyr_get_field_as_utf8(void *n, int j)
     590G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_field_as_utf8(void *n, int j)
    591591{
    592592  return owl_zephyr_get_field(n, j);
     
    621621 * caller must free the return
    622622 */
    623 char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
     623G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_get_message(const ZNotice_t *n, const owl_message *m)
    624624{
    625625#define OWL_NFIELDS     5
     
    942942#endif
    943943
    944 char *owl_zephyr_zlocate(const char *user, int auth)
     944G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_zlocate(const char *user, int auth)
    945945{
    946946#ifdef HAVE_LIBZEPHYR
     
    10421042
    10431043/* caller must free the return */
    1044 char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
     1044G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_makesubline(const char *class, const char *inst, const char *recip)
    10451045{
    10461046  return g_strdup_printf("%s,%s,%s\n", class, inst, !strcmp(recip, "") ? "*" : recip);
     
    11221122 * free the return.
    11231123 */
    1124 char *owl_zephyr_getsubs(void)
     1124G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_getsubs(void)
    11251125{
    11261126#ifdef HAVE_LIBZEPHYR
     
    12421242 * The caller must free the return
    12431243 */
    1244 char *short_zuser(const char *in)
     1244G_GNUC_WARN_UNUSED_RESULT char *short_zuser(const char *in)
    12451245{
    12461246  char *ptr = strrchr(in, '@');
     
    12541254 * The caller must free the return.
    12551255 */
    1256 char *long_zuser(const char *in)
     1256G_GNUC_WARN_UNUSED_RESULT char *long_zuser(const char *in)
    12571257{
    12581258  char *ptr = strrchr(in, '@');
     
    12821282 * caller must free the return.
    12831283 */
    1284 char *owl_zephyr_smartstripped_user(const char *in)
     1284G_GNUC_WARN_UNUSED_RESULT char *owl_zephyr_smartstripped_user(const char *in)
    12851285{
    12861286  char *slash, *dot, *realm, *out;
  • zwrite.c

    r3b8a563 rd427f08  
    55#include "owl.h"
    66
    7 owl_zwrite *owl_zwrite_new(const char *line)
     7G_GNUC_WARN_UNUSED_RESULT owl_zwrite *owl_zwrite_new(const char *line)
    88{
    99  owl_zwrite *z = g_new(owl_zwrite, 1);
     
    1515}
    1616
    17 int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
     17G_GNUC_WARN_UNUSED_RESULT int owl_zwrite_create_from_line(owl_zwrite *z, const char *line)
    1818{
    1919  int argc, badargs, myargc;
     
    321321
    322322/* Caller must free the result. */
    323 char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
     323G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_recip_n_with_realm(const owl_zwrite *z, int n)
    324324{
    325325  if (z->realm[0]) {
     
    370370 * If not a CC, only the recip_index'th user will be replied to.
    371371 */
    372 char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
     372G_GNUC_WARN_UNUSED_RESULT char *owl_zwrite_get_replyline(const owl_zwrite *z, int recip_index)
    373373{
    374374  /* Match ordering in zwrite help. */
Note: See TracChangeset for help on using the changeset viewer.