Skip to content

Commit

Permalink
Version19.76.6
Browse files Browse the repository at this point in the history
  • Loading branch information
acanas committed Nov 22, 2019
1 parent ffc56bc commit 14fd5e4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 31 deletions.
3 changes: 2 additions & 1 deletion swad_changelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,14 +490,15 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 19.76.5 (2019-11-22)"
#define Log_PLATFORM_VERSION "SWAD 19.76.6 (2019-11-22)"
#define CSS_FILE "swad19.74.3.css"
#define JS_FILE "swad19.70.js"
/*
// TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de �reas no vinculadas con el centro, profesionales de empresas, etc.)
// TODO: Impedir la creaci�n y edici�n de proyectos si no son editables.
// TODO: En cada juego, poder listar los resultados en una tabla como la de resultados globales

Version 19.76.6: Nov 22, 2019 Code refactoring in forums and strings. (246845 lines)
Version 19.76.5: Nov 22, 2019 Code refactoring related to vectors. (246852 lines)
Version 19.76.4: Nov 22, 2019 Code refactoring related to vectors. (246851 lines)
Version 19.76.3: Nov 21, 2019 Code refactoring related to vectors. (246850 lines)
Expand Down
12 changes: 2 additions & 10 deletions swad_forum.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,16 +1399,8 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1
row = mysql_fetch_row (mysql_res);

/***** Copy subject *****/
// TODO: Do only direct copy when Subject will be VARCHAR(255)
if (strlen (row[0]) > Ntf_MAX_BYTES_SUMMARY)
{
strncpy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
SummaryStr[Ntf_MAX_BYTES_SUMMARY] = '\0';
}
else
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);
Str_Copy (SummaryStr,row[0],
Ntf_MAX_BYTES_SUMMARY);

/***** Copy content *****/
if (GetContent)
Expand Down
40 changes: 20 additions & 20 deletions swad_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2650,7 +2650,7 @@ int Str_ReadFileUntilBoundaryStr (FILE *FileSrc,char *StrDst,
unsigned StartIndex;
unsigned i;
char *Ptr; // Pointer used to go through StrDst writing characters
unsigned long long LengthDst;
unsigned long long DstLength;

/***** Checkings on boundary string *****/
if (!LengthBoundaryStr)
Expand All @@ -2665,7 +2665,7 @@ int Str_ReadFileUntilBoundaryStr (FILE *FileSrc,char *StrDst,

StartIndex = 0;
NumBytesReadButNotDiscarded = 0;
LengthDst = 0;
DstLength = 0;

for (;;)
{
Expand Down Expand Up @@ -2709,7 +2709,7 @@ int Str_ReadFileUntilBoundaryStr (FILE *FileSrc,char *StrDst,
}
}

if (LengthDst == MaxLength)
if (DstLength == MaxLength)
{
if (StrDst != NULL)
*Ptr = '\0';
Expand All @@ -2721,7 +2721,7 @@ int Str_ReadFileUntilBoundaryStr (FILE *FileSrc,char *StrDst,

StartIndex = (StartIndex + 1) % LengthBoundaryStr;
NumBytesReadButNotDiscarded--;
LengthDst++;
DstLength++;
}

return 0; // Not reached
Expand Down Expand Up @@ -2912,14 +2912,14 @@ void Str_CreateRandomAlphanumStr (char *Str,size_t Length)
void Str_Copy (char *Dst,const char *Src,size_t DstSize)
{
char ErrorTxt[128];
size_t LengthSrc = strlen (Src);
size_t SrcLength = strlen (Src);

/***** Check if buffer has enough space for source *****/
if (LengthSrc > DstSize)
if (SrcLength > DstSize)
{
snprintf (ErrorTxt,sizeof (ErrorTxt),
"Trying to copy %lu chars into a %lu-chars buffer.",
LengthSrc,DstSize);
"Trying to copy %zu chars into a %zu-chars buffer.",
SrcLength,DstSize);
Lay_ShowErrorAndExit (ErrorTxt);
}

Expand All @@ -2934,31 +2934,31 @@ void Str_Copy (char *Dst,const char *Src,size_t DstSize)

void Str_Concat (char *Dst,const char *Src,size_t DstSize)
{
size_t LengthDst;
size_t LengthSrc;
size_t DstLength;
size_t SrcLength;
size_t FreeSpace;
char ErrorTxt[256];

/***** Check if buffer has already overflowed *****/
LengthDst = strlen (Dst);
if (LengthDst > DstSize)
DstLength = strlen (Dst);
if (DstLength > DstSize)
{
snprintf (ErrorTxt,sizeof (ErrorTxt),
"%lu-chars buffer has %lu chars!",
DstSize,LengthDst);
DstSize,DstLength);
Lay_ShowErrorAndExit (ErrorTxt);
}

/***** Check if buffer has enough space for source *****/
// DstSize >= LengthDst ==> FreeSpace >= 0
FreeSpace = DstSize - LengthDst;
LengthSrc = strlen (Src);
if (FreeSpace < LengthSrc)
// DstSize >= DstLength ==> FreeSpace >= 0
FreeSpace = DstSize - DstLength;
SrcLength = strlen (Src);
if (FreeSpace < SrcLength)
{
snprintf (ErrorTxt,sizeof (ErrorTxt),
"Trying to concatenate %lu chars to a %lu-chars buffer"
" with free space for only %lu chars!",
LengthSrc,DstSize,FreeSpace);
"Trying to concatenate %zu chars to a %zu-chars buffer"
" with free space for only %zu chars!",
SrcLength,DstSize,FreeSpace);
Lay_ShowErrorAndExit (ErrorTxt);
}

Expand Down

0 comments on commit 14fd5e4

Please sign in to comment.