[mw-devel] MW3 r1077 - trunk/src

arthur at sucs.org arthur at sucs.org
Mon Mar 16 17:58:32 GMT 2009


Author: arthur
Date: 2009-03-16 17:58:32 +0000 (Mon, 16 Mar 2009)
New Revision: 1077

Modified:
   trunk/src/log.c
   trunk/src/sqlite.c
Log:
reorganise hashtag storing code to fix -log issues, exclude C preprocesor statements, and ask sqlite to do busy wait locking


Modified: trunk/src/log.c
===================================================================
--- trunk/src/log.c	2009-03-16 10:18:33 UTC (rev 1076)
+++ trunk/src/log.c	2009-03-16 17:58:32 UTC (rev 1077)
@@ -76,6 +76,14 @@
 	{"nsfw", 		REG_ICASE, NULL, FLAG,   URLFLAG_NSFW},
 	{"^-log", 		REG_ICASE, NULL, NOLOG, 0},
 	{"^(-log)$", 		REG_ICASE, NULL, NOLOG, 0},
+	/* section for hashtags, exclude C preprocessor directives */
+	{"^#include$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^#define$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^#pragma$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^#if$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^#ifdef$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^#ifndef$", 		REG_ICASE, NULL, IGNORE, 0},
+	{"^#endif$", 		REG_ICASE, NULL, IGNORE, 0},
 	{"^#[[:alnum:]]+$",	REG_ICASE|REG_EXTENDED, NULL, TAG, 0},
 	{ NULL, 0, NULL, END, 0 }
 };
@@ -95,8 +103,10 @@
 	char *text = strdup(what);
 	char *token;
 	/* kludge, find at most 20 URLs */
-	char *found[20];
-	int nfound=0;
+	char *foundurl[20];
+	int nfoundurl=0;
+	char *foundtag[20];
+	int nfoundtag=0;
 	uint32_t flags = 0;
 
 	/* split the line into words on whitespace */
@@ -124,7 +134,7 @@
 				if (u->type == URL) {
 					/* found a url */
 					/*printf("Found url: '%s'\n", token); */
-					if (nfound < 20) found[nfound++] = token;
+					if (nfoundurl < 20) foundurl[nfoundurl++] = token;
 				} 
 				if (u->type == FLAG) {
 					/* printf("Found flag: '%s' -> %x\n", token, u->flags); */
@@ -137,6 +147,8 @@
 					return;
 				}
 				if (u->type == TAG) {
+					if (nfoundtag < 20) foundurl[nfoundtag++] = token;
+
 					struct taghit *tag;
 					pthread_attr_t ptattr;
 
@@ -159,21 +171,39 @@
 	 * categorise and file the details
 	 * cant do it in foreground, would stall the ui
 	 */
-	if (nfound>0) {
+	if (nfoundurl>0) {
 		int i;
 		pthread_attr_t ptattr;
 		pthread_attr_init(&ptattr);
 		pthread_attr_setdetachstate(&ptattr, PTHREAD_CREATE_DETACHED);
-		for (i=0;i<nfound;i++) {
+		for (i=0;i<nfoundurl;i++) {
 			struct urihit *uri;
 			pthread_t pt;
 			uri = malloc(sizeof(struct urihit));
-			uri->url = strdup(found[i]);
+			uri->url = strdup(foundurl[i]);
 			uri->flags = flags;
 			pthread_create(&pt, &ptattr, file_url, uri);
 		}
 		pthread_attr_destroy(&ptattr);
 	}
+
+	/* we also found some tags */
+	if (nfoundtag>0) {
+		int i;
+		pthread_attr_t ptattr;
+
+		pthread_attr_init(&ptattr);
+		pthread_attr_setdetachstate(&ptattr, PTHREAD_CREATE_DETACHED);
+		for (i=0;i<nfoundtag;i++) {
+			struct taghit *tag;
+			pthread_t pt;
+			tag = malloc(sizeof(struct taghit));
+			tag->tag = strdup(foundtag[i]);
+			tag->line = strdup(what);
+			pthread_create(&pt, &ptattr, file_tag, tag);
+		}
+		pthread_attr_destroy(&ptattr);
+	}
 	free(text);
 }
 

Modified: trunk/src/sqlite.c
===================================================================
--- trunk/src/sqlite.c	2009-03-16 10:18:33 UTC (rev 1076)
+++ trunk/src/sqlite.c	2009-03-16 17:58:32 UTC (rev 1077)
@@ -15,6 +15,7 @@
 		printf("Error opening db %s: %s\n", dbname, sqlite3_errmsg(db));
 		return NULL;
 	}
+	sqlite3_busy_timeout(db, 500);
 	return db;
 }
 





More information about the mw-devel mailing list