cinera: s/StringLength()/sizeof()-1 on string lits

This commit is contained in:
Matt Mascarenhas 2021-05-31 21:01:34 +01:00
parent 63ab9d5bc2
commit af1bff4218
2 changed files with 12 additions and 12 deletions

View File

@ -23,7 +23,7 @@ typedef struct
version CINERA_APP_VERSION = {
.Major = 0,
.Minor = 8,
.Patch = 15
.Patch = 16
};
#include <stdarg.h> // NOTE(matt): varargs
@ -7550,7 +7550,7 @@ GenerateTopicColours(neighbourhood *N, string Topic)
bool Exists = FALSE;
while(Topics.Buffer.Ptr - Topics.Buffer.Location < Topics.Buffer.Size)
{
Topics.Buffer.Ptr += StringLength(".category.");
Topics.Buffer.Ptr += sizeof(".category.")-1;
if(!StringsDifferT(SanitisedTopic, Topics.Buffer.Ptr, ' '))
{
Exists = TRUE;
@ -8012,7 +8012,7 @@ DepartComment(buffer *Template)
{
if(!StringsDifferT("-->", Template->Ptr, 0))
{
Template->Ptr += StringLength("-->");
Template->Ptr += sizeof("-->")-1;
break;
}
++Template->Ptr;
@ -8386,7 +8386,7 @@ NextTagSearch:
if(*Template->File.Buffer.Ptr == '!' && (Template->File.Buffer.Ptr > Template->File.Buffer.Location && !StringsDifferT("<!--", &Template->File.Buffer.Ptr[-1], 0)))
{
char *CommentStart = &Template->File.Buffer.Ptr[-1];
Template->File.Buffer.Ptr += StringLength("!--");
Template->File.Buffer.Ptr += sizeof("!--")-1;
while(Template->File.Buffer.Ptr - Template->File.Buffer.Location < Template->File.Buffer.Size && StringsDifferT("-->", Template->File.Buffer.Ptr, 0))
{
for(template_tag_code TagIndex = 0; TagIndex < TEMPLATE_TAG_COUNT; ++TagIndex)
@ -10228,7 +10228,7 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
// TODO(matt): A "MakeString0OnStack()" sort of function?
// NOTE(matt): Stack-string
int NullTerminationBytes = 1;
char Filepath[CurrentProject->HMMLDir.Length + StringLength("/") + BaseFilename.Length + ExtensionStrings[EXT_HMML].Length + NullTerminationBytes];
char Filepath[CurrentProject->HMMLDir.Length + sizeof("/")-1 + BaseFilename.Length + ExtensionStrings[EXT_HMML].Length + NullTerminationBytes];
char *P = Filepath;
P += CopyStringToBarePtr(P, CurrentProject->HMMLDir);
P += CopyStringToBarePtr(P, Wrap0("/"));
@ -10772,7 +10772,7 @@ HMMLToBuffers(buffers *CollationBuffers, template *BespokeTemplate, string BaseF
NullTopic ? "title=\"Timestamps that don't fit into the above topic(s) may be filtered using this pseudo-topic\" " : "",
SanitisedMarker,
SanitisedMarker,
NullTopic ? (int)StringLength("(null topic)") : (int)This->Marker.Length,
NullTopic ? (int)sizeof("(null topic)-1") : (int)This->Marker.Length,
NullTopic ? "(null topic)" : This->Marker.Base);
}
CopyStringToBuffer(&MenuBuffers.FilterTopics,
@ -11868,7 +11868,7 @@ AccumulateDBEntryInsertionOffset(db_header_project *Header, int EntryIndex)
Result += Entry->Size;
--Entry;
}
Result += StringLength("---\n");
Result += sizeof("---\n")-1;
}
else
{
@ -12196,7 +12196,7 @@ InsertIntoDB(neighbourhood *N, buffers *CollationBuffers, template *BespokeTempl
db_entry *Result = 0;
ResetNeighbourhood(N);
edit_type_id EditType = EDIT_APPEND;
int EntryInsertionStart = StringLength("---\n");
int EntryInsertionStart = sizeof("---\n")-1;
int EntryInsertionEnd = 0;
if(N->Project->EntryCount > 0)
@ -15200,7 +15200,7 @@ InitProjectInDBRecursively(project_generations *G, project *P)
while((BaseDirFiles = readdir(BaseDirHandle)) && !RemovedOldMetadataFile)
{
char *Ptr = BaseDirFiles->d_name;
Ptr += (StringLength(BaseDirFiles->d_name) - StringLength(".metadata"));
Ptr += (StringLength(BaseDirFiles->d_name) - sizeof(".metadata")-1);
if(!(StringsDiffer0(Ptr, ".metadata")))
{
char *MetadataPath = MakeString0("lss", &P->BaseDir, "/", BaseDirFiles->d_name);
@ -15214,7 +15214,7 @@ InitProjectInDBRecursively(project_generations *G, project *P)
{
// NOTE(matt): Stack-string
int NullTerminationBytes = 1;
char IndexPath[P->BaseDir.Length + StringLength("/") + Filename.Length + NullTerminationBytes];
char IndexPath[P->BaseDir.Length + sizeof("/")-1 + Filename.Length + NullTerminationBytes];
char *Ptr = IndexPath;
Ptr += CopyStringToBarePtr(Ptr, P->BaseDir);
Ptr += CopyStringToBarePtr(Ptr, Wrap0("/"));

View File

@ -4350,8 +4350,8 @@ PrintLineage(string Lineage, bool AppendNewline)
uint8_t
GetColumnsRequiredForMedium(medium *M, typography *T)
{
uint8_t Result = M->ID.Length + StringLength(T->Delimiter) + M->Name.Length + StringLength(" (") + M->Icon.Length + StringLength(")");
if(M->Hidden) { Result += StringLength(" [hidden]"); }
uint8_t Result = M->ID.Length + StringLength(T->Delimiter) + M->Name.Length + sizeof(" (")-1 + M->Icon.Length + sizeof(")")-1;
if(M->Hidden) { Result += sizeof(" [hidden]")-1; }
return Result;
}