comparison main.c @ 339:6ee1ed15688c

twitter markups tags like "#2.0" as "#2" but those tags only be matched with the query of "#2.0". so, we should handle a punctuation within a string as a normal letter and should strip it only if it is followed by white space.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sun, 18 Oct 2009 13:30:48 +0900
parents 9f78fb6bfc76
children 2b79bad516e6
comparison
equal deleted inserted replaced
338:cdcfdf6a15fb 339:6ee1ed15688c
226 g_free(match2); 226 g_free(match2);
227 } 227 }
228 else if(which == SENDER_FFEED) { 228 else if(which == SENDER_FFEED) {
229 gchar *match1 = g_match_info_fetch(match_info, 1); /* preceding CR|LF */ 229 gchar *match1 = g_match_info_fetch(match_info, 1); /* preceding CR|LF */
230 gchar *match2 = g_match_info_fetch(match_info, 2); /* sender */ 230 gchar *match2 = g_match_info_fetch(match_info, 2); /* sender */
231 const gchar *format = NULL; 231
232 232 g_snprintf(sub, SUBST_BUF_SIZE, SENDER_FORMAT_FFEED, match1 ? match1: "", match2, match2);
233 format = SENDER_FORMAT_FFEED;
234 g_snprintf(sub, SUBST_BUF_SIZE, format, match1 ? match1: "", match2, match2);
235 233
236 g_free(match1); 234 g_free(match1);
237 g_free(match2); 235 g_free(match2);
238 } 236 }
239 else if(which == CHANNEL_WASSR && service == wassr_service) { 237 else if(which == CHANNEL_WASSR && service == wassr_service) {
240 gchar *match1 = g_match_info_fetch(match_info, 1); /* before channel */ 238 gchar *match1 = g_match_info_fetch(match_info, 1); /* before channel */
241 gchar *match2 = g_match_info_fetch(match_info, 2); /* channel */ 239 gchar *match2 = g_match_info_fetch(match_info, 2); /* channel */
242 const gchar *format = CHANNEL_FORMAT_WASSR; 240
243 241 g_snprintf(sub, SUBST_BUF_SIZE, CHANNEL_FORMAT_WASSR, match1 ? match1: "", match2, match2);
244 g_snprintf(sub, SUBST_BUF_SIZE, format, match1 ? match1: "", match2, match2);
245 242
246 g_free(match1); 243 g_free(match1);
247 g_free(match2); 244 g_free(match2);
248 } 245 }
249 else if(which == TAG_TWITTER && service == twitter_service) { 246 else if(which == TAG_TWITTER && service == twitter_service) {
250 gchar *match1 = g_match_info_fetch(match_info, 1); /* white space */ 247 gchar *match1 = g_match_info_fetch(match_info, 1); /* white space */
251 gchar *match2 = g_match_info_fetch(match_info, 2); /* search tag */ 248 gchar *match2 = g_match_info_fetch(match_info, 2); /* search tag */
252 const gchar *format = TAG_FORMAT_TWITTER; 249
253 g_snprintf(sub, SUBST_BUF_SIZE, format, match1 ? match1: "", match2, match2); 250 /* search tag ambiguity hack */
251 gchar *last;
252 last = match2 + strlen(match2) - 1;
253 if(g_ascii_ispunct(*last))
254 *last = '\0';
255
256 g_snprintf(sub, SUBST_BUF_SIZE, TAG_FORMAT_TWITTER, match1 ? match1: "", match2, match2);
254 g_free(match1); 257 g_free(match1);
255 g_free(match2); 258 g_free(match2);
256 } 259 }
257 else if(which == TAG_IDENTICA && service == identica_service) { 260 else if(which == TAG_IDENTICA && service == identica_service) {
258 gchar *match = g_match_info_fetch(match_info, 1); 261 gchar *match = g_match_info_fetch(match_info, 1);