From 3a9d9c5140bf900a9b24e71d767816c04a05aba8 Mon Sep 17 00:00:00 2001 From: cheapie Date: Thu, 13 Aug 2015 03:15:52 -0400 Subject: Sparkles 1.1 --- sparkles.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'sparkles.c') diff --git a/sparkles.c b/sparkles.c index 494be9d..6665d2f 100644 --- a/sparkles.c +++ b/sparkles.c @@ -185,11 +185,16 @@ int memcasecmp(const char *Text1, const char *Text2, int Length) { } static int isgraph2(char k) { // unicode version - if(!isgraph(k)) return 0; unsigned char k2 = (unsigned char)k; + if(!isgraph(k) && k2 < 0xc0) return 0; return k2<0x80||k2>0xbf; } +static int iscontinuationbyte(char k) { + unsigned char k2 = (unsigned char)k; + return k2>=0x80&&k2<=0xbf; +} + static char *ReadTextFile(const char *Name) { FILE *File = fopen(Name,"rb"); if(!File) return NULL; @@ -271,10 +276,10 @@ static int OETextMatch(char *Inputs[], const char *MatchTo) { case 1: // *@ End = strrchr(Input, 0); End -= strlen(Match); - Decision = memcasecmp(End, Match, strlen(Match)); + Decision = !memcasecmp(End, Match, strlen(Match)); break; case 2: // @* - Decision = memcasecmp(Input, Match, strlen(Match)); + Decision = !memcasecmp(Input, Match, strlen(Match)); break; case 3: // *@* Decision = strstr(Input, Match) != NULL; @@ -384,9 +389,15 @@ static int on_event_cb(char *word[], void *userdata) { xchat_free(ph, Word3); xchat_free(ph, Word4); + if(!strcasecmp(Buffer, "DeleteEvent")) + return XCHAT_EAT_ALL; + xchat_command(ph, Buffer); - if(Info->Flags & OEF_TEMPORARY) + if(Info->Flags & OEF_TEMPORARY) { + QuietOnEvents++; xchat_commandf(ph, "spark onevent delete %i", Info->Slot); + QuietOnEvents--; + } return XCHAT_EAT_NONE; } @@ -808,6 +819,12 @@ static int AttributeLoop(char *Out, char *In, char *Loop) { int LoopTimes = 0; for(;iFlags & OEF_SAVE) { + ListOnEvent(Buffer, OnEventInfos[i]); + fprintf(Output, "%i=%s\n", i, Buffer); + } fclose(Output); xchat_print(ph, "Saved Sparkles preferences\n"); } @@ -2938,6 +2961,7 @@ static int Spark_cb(char *word[], char *word_eol[], void *userdata) { OnEventInfos[i] = OnEventInfos[j]; OnEventInfos[j] = NULL; OnEventInfos[i]->Slot = i; + break; } } xchat_print(ph, "Renumbered the OnEvent list"); @@ -2967,7 +2991,7 @@ static int Spark_cb(char *word[], char *word_eol[], void *userdata) { if(OnEventInfos[j]) { OnEventInfos[j]->Flags &= ~OEF_ENABLED; if(!QuietOnEvents) - xchat_printf(ph, "Disabling OnEvent item %i", i); + xchat_printf(ph, "Disabling OnEvent item %i", j); } } } else if(!strcasecmp(word[3], "enable")) { @@ -2976,13 +3000,16 @@ static int Spark_cb(char *word[], char *word_eol[], void *userdata) { if(OnEventInfos[j]) { OnEventInfos[j]->Flags |= OEF_ENABLED; if(!QuietOnEvents) - xchat_printf(ph, "Enabling OnEvent item %i", i); + xchat_printf(ph, "Enabling OnEvent item %i", j); } } } else if(!strcasecmp(word[3], "set")) { j = -1; - if(isdigit(word[4][0])) // user selected a specific slot + if(isdigit(word[4][0])) { // user selected a specific slot j = strtol(word[4], NULL, 10); + if(j < 0 || j >= ONEVENTS_SIZE) + return XCHAT_EAT_ALL; + } if(j == -1) { for(j=0;j