Add patch to remove some more references to identi.ca
[debian/bti.git] / config.c
index 346fed8ceaacc83d4b86d2c7f68424a9d4df9f35..e6fecc1d3975f350ddb4e6267566d454d4d0c5f1 100644 (file)
--- a/config.c
+++ b/config.c
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
 #define _GNU_SOURCE
@@ -227,10 +223,6 @@ static int host_callback(struct session *session, char *value)
                session->host = HOST_TWITTER;
                session->hosturl = strdup(twitter_host);
                session->hostname = strdup(twitter_name);
-       } else if (strcasecmp(value, "identica") == 0) {
-               session->host = HOST_IDENTICA;
-               session->hosturl = strdup(identica_host);
-               session->hostname = strdup(identica_name);
        } else {
                session->host = HOST_CUSTOM;
                session->hosturl = strdup(value);
@@ -254,7 +246,7 @@ static int action_callback(struct session *session, char *value)
        else if (strcasecmp(value, "group") == 0)
                session->action = ACTION_GROUP;
        else
-               session->action= ACTION_UNKNOWN;
+               session->action = ACTION_UNKNOWN;
        return 0;
 }
 
@@ -311,7 +303,7 @@ static void process_line(struct session *session, char *key, char *value)
                if (strncasecmp(item->key, key, strlen(item->key)) == 0) {
                        /*
                         * printf("calling %p, for key = '%s' and value = * '%s'\n",
-                        *        item->callback, key, value);
+                        *        item->callback, key, value);
                         */
                        result = item->callback(session, value);
                        if (!result)
@@ -327,6 +319,7 @@ void bti_parse_configfile(struct session *session)
        char *line = NULL;
        char *key = NULL;
        char *value = NULL;
+       char *hashmarker;
        size_t len = 0;
        ssize_t n;
        char *c;
@@ -344,8 +337,30 @@ void bti_parse_configfile(struct session *session)
                if (line[n - 1] == '\n')
                        line[n - 1] = '\0';
 
-               /* '#' is comment markers, like bash style */
-               *strchrnul(line, '#') = '\0';
+               /*
+                * '#' is comment markers, like bash style but it is a valid
+                * character in some fields, so only treat it as a comment
+                * marker if it occurs at the beginning of the line, or after
+                * whitespace
+                */
+               hashmarker = strchr(line, '#');
+               if (line == hashmarker)
+                       line[0] = '\0';
+               else {
+                       while (hashmarker != NULL) {
+                               --hashmarker;
+                               if (isblank(hashmarker[0])) {
+                                       hashmarker[0] = '\0';
+                                       break;
+                               } else {
+                                       /*
+                                        * false positive; '#' occured
+                                        * within a string
+                                        */
+                                       hashmarker = strchr(hashmarker+2, '#');
+                               }
+                       }
+               }
                c = line;
                while (isspace(*c))
                        c++;