[hackers] [surf] Do not build SiteSpecific file when regex is invalid || Quentin Rameau

From: <git_AT_suckless.org>
Date: Sun, 30 Apr 2017 23:25:10 +0200 (CEST)

commit 0d1e670ac3e6a5ea02ff1c6a6e64263b425aef9c
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Fri Apr 28 13:09:39 2017 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Fri Apr 28 13:09:39 2017 +0200

    Do not build SiteSpecific file when regex is invalid

diff --git a/surf.c b/surf.c
index d61534b..fcaa506 100644
--- a/surf.c
+++ b/surf.c
_AT_@ -299,26 +299,28 @@ setup(void)
         gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
 
         for (i = 0; i < LENGTH(certs); ++i) {
- if (regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) {
+ if (!regcomp(&(certs[i].re), certs[i].regex, REG_EXTENDED)) {
+ certs[i].file = g_strconcat(certdir, "/", certs[i].file,
+ NULL);
+ } else {
                         fprintf(stderr, "Could not compile regex: %s\n",
                                 certs[i].regex);
                         certs[i].regex = NULL;
                 }
- certs[i].file = g_strconcat(certdir, "/", certs[i].file, NULL);
         }
 
         if (!stylefile) {
                 styledir = buildpath(styledir);
                 for (i = 0; i < LENGTH(styles); ++i) {
- if (regcomp(&(styles[i].re), styles[i].regex,
+ if (!regcomp(&(styles[i].re), styles[i].regex,
                             REG_EXTENDED)) {
- fprintf(stderr,
- "Could not compile regex: %s\n",
+ styles[i].file = g_strconcat(styledir, "/",
+ styles[i].file, NULL);
+ } else {
+ fprintf(stderr, "Could not compile regex: %s\n",
                                         styles[i].regex);
                                 styles[i].regex = NULL;
                         }
- styles[i].file = g_strconcat(styledir, "/",
- styles[i].file, NULL);
                 }
                 g_free(styledir);
         } else {
_AT_@ -336,8 +338,7 @@ setup(void)
                                         uriparams[i].config[j] = defconfig[j];
                         }
                 } else {
- fprintf(stderr,
- "Could not compile regex: %s\n",
+ fprintf(stderr, "Could not compile regex: %s\n",
                                 uriparams[i].uri);
                         uriparams[i].uri = NULL;
                 }
Received on Sun Apr 30 2017 - 23:25:10 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 30 2017 - 23:36:31 CEST