From f153d73a0c8e6d5092cf579d6b66fcd53e865a58 Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Wed, 24 Apr 2024 14:51:59 +0800 Subject: [PATCH 1/3] Switch to using 'snprintf' to avoid warnings --- src/json.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/json.cc b/src/json.cc index da7155f..56ce6cb 100644 --- a/src/json.cc +++ b/src/json.cc @@ -188,7 +188,7 @@ static Obj FuncJSON_ESCAPE_STRING(Obj self, Obj param) return param; // Massively over-long string - Obj copy = NEW_STRING(lenString * 6); + Obj copy = NEW_STRING(lenString * 6 + 7); UChar * base = CHARS_STRING(copy); UChar * out = base; Int i = 1; @@ -211,7 +211,7 @@ static Obj FuncJSON_ESCAPE_STRING(Obj self, Obj param) default: if(u < ' ') { - sprintf((char*)out,"\\u%04X",(unsigned)u); + snprintf((char*)out,7, "\\u%04X",(unsigned)u); out += 6; } else From 9ac10cdf3b4ed6f83ed6fad543e2fdfc85d610fb Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Wed, 24 Apr 2024 14:53:13 +0800 Subject: [PATCH 2/3] Update my website --- PackageInfo.g | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PackageInfo.g b/PackageInfo.g index 53a8036..11e9a8b 100644 --- a/PackageInfo.g +++ b/PackageInfo.g @@ -20,7 +20,7 @@ Persons := [ IsMaintainer := true, FirstNames := "Christopher", LastName := "Jefferson", - WWWHome := "http://caj.host.cs.st-andrews.ac.uk/", + WWWHome := "https://heather.cafe/", Email := "caj21@st-andrews.ac.uk", PostalAddress := Concatenation( "St Andrews\n", From 59436c9d9e25765b10b855d87c3392e3e9be7af7 Mon Sep 17 00:00:00 2001 From: Chris Jefferson Date: Wed, 24 Apr 2024 14:54:33 +0800 Subject: [PATCH 3/3] Remove internal copy of AppendCStr --- src/json.cc | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/json.cc b/src/json.cc index 56ce6cb..219bdb0 100644 --- a/src/json.cc +++ b/src/json.cc @@ -226,21 +226,6 @@ static Obj FuncJSON_ESCAPE_STRING(Obj self, Obj param) return copy; } -// Local copy of AppendCStr, as it is a new method in 4.12 -void JSON_AppendCStr(Obj str, const char * buf, UInt len) -{ - GAP_ASSERT(IS_MUTABLE_OBJ(str)); - GAP_ASSERT(IS_STRING_REP(str)); - - UInt len1 = GET_LEN_STRING(str); - UInt newlen = len1 + len; - GROW_STRING(str, newlen); - SET_LEN_STRING(str, newlen); - CLEAR_FILTS_LIST(str); - memcpy(CHARS_STRING(str) + len1, buf, len); - CHARS_STRING(str)[newlen] = '\0'; // add terminator -} - static Obj FuncGAP_LIST_TO_JSON_STRING(Obj self, Obj string, Obj stream, Obj list) { RequireDenseList("list", list); Int len = LEN_LIST(list); @@ -248,15 +233,15 @@ static Obj FuncGAP_LIST_TO_JSON_STRING(Obj self, Obj string, Obj stream, Obj lis // Call this at the start ConvString(string); - JSON_AppendCStr(string, "[", 1); + AppendCStr(string, "[", 1); for(int i = 1; i <= len; ++i) { if(i != 1) { - JSON_AppendCStr(string, ",", 1); + AppendCStr(string, ",", 1); } Obj val = ELM_LIST(list, i); if(IS_INTOBJ(val)) { snprintf(buf, sizeof(buf), "%ld", INT_INTOBJ(val)); - JSON_AppendCStr(string, buf, strlen(buf)); + AppendCStr(string, buf, strlen(buf)); } else if(IS_LIST(val) && !(IS_STRING(val))) { FuncGAP_LIST_TO_JSON_STRING(self, string, stream, val); } else { @@ -265,7 +250,7 @@ static Obj FuncGAP_LIST_TO_JSON_STRING(Obj self, Obj string, Obj stream, Obj lis ConvString(string); } } - JSON_AppendCStr(string, "]", 1); + AppendCStr(string, "]", 1); return 0; }