Changeset c36f4d0


Ignore:
Timestamp:
Jul 23, 2011, 9:24:37 PM (10 years ago)
Author:
GitHub Merge Button <merge-button@github.com>
Parents:
4ebbfbc (diff), c40d11a (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 c40d11a3d527920acd6063b93f1de30d1f668c96 into 4ebbfbc5360fa004637dd101f5a0c833cdccd60a
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    refeec7f r83e023e  
    21652165      myargv[i]=argv[i];
    21662166    }
    2167     owl_function_create_filter(argc, myargv);
    2168     owl_function_change_currentview_filter("owl-dynamic");
     2167    if (owl_function_create_filter(argc, myargv)) {
     2168      owl_function_change_currentview_filter("owl-dynamic");
     2169    }
    21692170    g_free(myargv);
    21702171    return NULL;
  • functions.c

    r4ebbfbc rc36f4d0  
    21322132
    21332133/* Create a new filter, or replace an existing one
    2134  * with a new definition.
     2134 * with a new definition. Returns true on success.
    21352135 */
    2136 void owl_function_create_filter(int argc, const char *const *argv)
     2136bool owl_function_create_filter(int argc, const char *const *argv)
    21372137{
    21382138  owl_filter *f;
     
    21422142  if (argc < 2) {
    21432143    owl_function_error("Wrong number of arguments to filter command");
    2144     return;
     2144    return false;
    21452145  }
    21462146
     
    21522152  if (!strcmp(argv[1], "all")) {
    21532153    owl_function_error("You may not change the 'all' filter.");
    2154     return;
     2154    return false;
    21552155  }
    21562156
     
    21602160    if (!f) {
    21612161      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2162       return;
     2162      return false;
    21632163    }
    21642164    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21652165      owl_function_error("The color '%s' is not available.", argv[3]);
    2166       return;
     2166      return false;
    21672167    }
    21682168    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21692169    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2170     return;
     2170    return false;
    21712171  }
    21722172  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21742174    if (!f) {
    21752175      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2176       return;
     2176      return false;
    21772177    }
    21782178    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21792179      owl_function_error("The color '%s' is not available.", argv[3]);
    2180       return;
     2180      return false;
    21812181    }
    21822182    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21832183    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2184     return;
     2184    return true;
    21852185  }
    21862186
     
    21892189  if (f == NULL) {
    21902190    owl_function_error("Invalid filter");
    2191     return;
     2191    return false;
    21922192  }
    21932193
     
    22102210  }
    22112211  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2212  return true;
    22122213}
    22132214
  • owl.h

    r67e5ba36 rc40d11a  
    7575
    7676#define OWL_CONFIG_DIR "/.owl"             /* this is relative to the user's home directory */
    77 #define OWL_STARTUP_FILE "/.owl/startup"   /* this is relative to the user's home directory */
    7877
    7978#define OWL_FMTEXT_ATTR_NONE      0
     
    206205#define OWL_META(key) ((key)|010000)
    207206/* OWL_CTRL is definied in kepress.c */
    208 
    209 #define LINE 2048
    210207
    211208#ifdef HAVE_LIBZEPHYR
  • regex.c

    rd427f08 rc40d11a  
    1111{
    1212  int ret;
    13   char buff1[LINE];
     13  size_t errbuf_size;
     14  char *errbuf;
    1415  const char *ptr;
    1516 
     
    2627  ret=regcomp(&(re->re), ptr, REG_EXTENDED|REG_ICASE);
    2728  if (ret) {
    28     regerror(ret, NULL, buff1, LINE);
    29     owl_function_makemsg("Error in regular expression: %s", buff1);
     29    errbuf_size = regerror(ret, NULL, NULL, 0);
     30    errbuf = g_new(char, errbuf_size);
     31    regerror(ret, NULL, errbuf, errbuf_size);
     32    owl_function_error("Error in regular expression: %s", errbuf);
     33    g_free(errbuf);
    3034    g_free(re->string);
    3135    re->string=NULL;
  • message.c

    r6500907 r4ebbfbc  
    4646 
    4747  /* save the time */
    48   m->time=time(NULL);
    49   m->timestr=g_strdup(ctime(&(m->time)));
    50   m->timestr[strlen(m->timestr)-1]='\0';
     48  m->time = time(NULL);
     49  m->timestr = owl_util_time_to_timestr(localtime(&m->time));
    5150
    5251  m->fmtext = NULL;
     
    796795  /* save the time, we need to nuke the string saved by message_init */
    797796  if (m->timestr) g_free(m->timestr);
    798   m->time=n->z_time.tv_sec;
    799   m->timestr=g_strdup(ctime(&(m->time)));
    800   m->timestr[strlen(m->timestr)-1]='\0';
     797  m->time = n->z_time.tv_sec;
     798  m->timestr = owl_util_time_to_timestr(localtime(&m->time));
    801799
    802800  /* set other info */
  • owl.c

    rb8a3e00 ra7fac14  
    389389}
    390390
    391 #define CHECK_RESULT(s, syscall) \
     391#define OR_DIE(s, syscall)      \
    392392  G_STMT_START {                 \
    393     if ((syscall) != 0) {        \
     393    if ((syscall) == -1) {       \
    394394      perror((s));               \
    395395      exit(1);                   \
     
    402402  sigset_t sigset;
    403403  int ret, i;
    404   const int signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGHUP, SIGILL,
    405                           SIGINT, SIGQUIT, SIGSEGV, SIGTERM, SIGWINCH };
     404  const int reset_signals[] = { SIGABRT, SIGBUS, SIGCHLD, SIGFPE, SIGILL,
     405                                SIGQUIT, SIGSEGV, };
     406  /* Don't bother resetting watched ones because owl_signal_init will. */
     407  const int watch_signals[] = { SIGWINCH, SIGTERM, SIGHUP, SIGINT, };
    406408
    407409  /* Sanitize our signals; the mask and dispositions from our parent
    408410   * aren't really useful. Signal list taken from equivalent code in
    409411   * Chromium. */
    410   CHECK_RESULT("sigemptyset", sigemptyset(&sigset));
     412  OR_DIE("sigemptyset", sigemptyset(&sigset));
    411413  if ((ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL)) != 0) {
    412414    errno = ret;
    413415    perror("pthread_sigmask");
    414   }
    415   for (i = 0; i < G_N_ELEMENTS(signals); i++) {
    416     CHECK_RESULT("sigaction", sigaction(signals[i], &sig_default, NULL));
     416    exit(1);
     417  }
     418  for (i = 0; i < G_N_ELEMENTS(reset_signals); i++) {
     419    OR_DIE("sigaction", sigaction(reset_signals[i], &sig_default, NULL));
    417420  }
    418421
    419422  /* Turn off SIGPIPE; we check the return value of write. */
    420   CHECK_RESULT("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));
     423  OR_DIE("sigaction", sigaction(SIGPIPE, &sig_ignore, NULL));
    421424
    422425  /* Register some signals with the signal thread. */
    423   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGWINCH));
    424   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGTERM));
    425   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGHUP));
    426   CHECK_RESULT("sigaddset", sigaddset(&sigset, SIGINT));
    427   owl_signal_init(&sigset, sig_handler, NULL);
     426  owl_signal_init(watch_signals, G_N_ELEMENTS(watch_signals),
     427                  sig_handler, NULL);
    428428}
    429429
  • perl/modules/Twitter/lib/BarnOwl/Module/Twitter/Handle.pm

    r7aa1fa5 r4ebbfbc  
    2929use BarnOwl;
    3030use BarnOwl::Message::Twitter;
    31 use POSIX qw(asctime);
     31use POSIX qw(strftime);
    3232
    3333use LWP::UserAgent;
     
    247247                       ($self->{cfg}->{account_nickname} ?
    248248                        "[$self->{cfg}->{account_nickname}]" : "") .
    249                         ": ratelimited until " . asctime(localtime($timeout)));
     249                        ": ratelimited until " . strftime('%c', localtime($timeout)));
    250250    } elsif(exists($ratelimit->{error})) {
    251251        $self->sleep(60*20);
  • signal.c

    r1d21d9f ra7fac14  
    11#include <errno.h>
     2#include <glib.h>
    23#include <pthread.h>
    34#include <signal.h>
     
    1314static void *signal_thread_func(void *data);
    1415
    15 /* Initializes the signal thread to listen for 'set' on a dedicated
     16static void dummy_handler(int signum)
     17{
     18  /* Do nothing. This should never get called. It'd be nice to report the error
     19   * or something, but you can't have nice things in a signal handler. */
     20}
     21
     22#define OR_DIE(s, syscall)       \
     23  G_STMT_START {                 \
     24    if ((syscall) == -1) {       \
     25      perror((s));               \
     26      exit(1);                   \
     27    }                            \
     28  } G_STMT_END
     29
     30/* Initializes the signal thread to listen for 'signals' on a dedicated
    1631 * thread. 'callback' is called *on the signal thread* when a signal
    1732 * is received.
     
    1934 * This function /must/ be called before any other threads are
    2035 * created. (Otherwise the signals will not get blocked correctly.) */
    21 void owl_signal_init(const sigset_t *set, void (*callback)(const siginfo_t*, void*), void *data) {
     36void owl_signal_init(const int *signals, int num_signals, void (*callback)(const siginfo_t*, void*), void *data) {
     37  struct sigaction sig_dummy = { .sa_handler = dummy_handler };
    2238  int ret;
     39  int i;
    2340
    24   signal_set = *set;
    2541  signal_cb = callback;
    2642  signal_cbdata = data;
     43
     44  /* Stuff the signals into our sigset_t. Also assign all of them to a dummy
     45   * handler. Otherwise, if their default is SIG_IGN, they will get dropped if
     46   * delivered while processing. On Solaris, they will not get delivered at
     47   * all. */
     48  OR_DIE("sigemptyset", sigemptyset(&signal_set));
     49  for (i = 0; i < num_signals; i++) {
     50    OR_DIE("sigaddset", sigaddset(&signal_set, signals[i]));
     51    OR_DIE("sigaction", sigaction(signals[i], &sig_dummy, NULL));
     52  }
     53
    2754  /* Block these signals in all threads, so we can get them. */
    28   if ((ret = pthread_sigmask(SIG_BLOCK, set, NULL)) != 0) {
     55  if ((ret = pthread_sigmask(SIG_BLOCK, &signal_set, NULL)) != 0) {
    2956    errno = ret;
    3057    perror("pthread_sigmask");
     58    exit(1);
    3159  }
    3260  /* Spawn a dedicated thread to sigwait. */
  • util.c

    r8219374 r4ebbfbc  
    296296}
    297297
     298CALLER_OWN char *owl_util_time_to_timestr(const struct tm *time)
     299{
     300  /* 32 chosen for first attempt because timestr will end up being
     301   * something like "Www Mmm dd hh:mm:ss AM yyyy UTC\0" */
     302  size_t timestr_size = 16;
     303  char *timestr = NULL;
     304  do {
     305    timestr_size *= 2;
     306    timestr = g_renew(char, timestr, timestr_size);
     307  } while (strftime(timestr, timestr_size, "%c", time) == 0);
     308  return timestr;
     309}
     310
    298311/* These are in order of their value in owl.h */
    299312static const struct {
Note: See TracChangeset for help on using the changeset viewer.