diff --git a/swad_HTML.c b/swad_HTML.c
index c14d673f..b362d493 100644
--- a/swad_HTML.c
+++ b/swad_HTML.c
@@ -27,7 +27,7 @@
#define _GNU_SOURCE // For vasprintf
#include // For va_start, va_end
-#include // For fprintf, vasprintf
+#include // For vasprintf
#include // For free
#include "swad_global.h"
diff --git a/swad_action.c b/swad_action.c
index 9e8628dc..0b3341f7 100644
--- a/swad_action.c
+++ b/swad_action.c
@@ -26,7 +26,6 @@
/*****************************************************************************/
#include // For NULL
-#include // For fprintf
#include // For string functions
#include "swad_account.h"
diff --git a/swad_alert.c b/swad_alert.c
index fd883ca0..c97749ef 100644
--- a/swad_alert.c
+++ b/swad_alert.c
@@ -28,7 +28,7 @@
#define _GNU_SOURCE // For vasprintf
#include // For va_start, va_end
#include // For NULL
-#include // For FILE, fprintf, vasprintf
+#include // For FILE, vasprintf
#include // For free
#include // For string functions
diff --git a/swad_box.c b/swad_box.c
index 9fcad786..575a2608 100644
--- a/swad_box.c
+++ b/swad_box.c
@@ -26,7 +26,6 @@
/*****************************************************************************/
#include // For boolean type
-#include // For fprintf
#include // For malloc and free
#include "swad_action.h"
diff --git a/swad_button.c b/swad_button.c
index 2e1bb86f..8c665d4d 100644
--- a/swad_button.c
+++ b/swad_button.c
@@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
-#include // For fprintf
-
#include "swad_button.h"
#include "swad_global.h"
#include "swad_HTML.h"
diff --git a/swad_changelog.h b/swad_changelog.h
index a3ce91da..cf16600d 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
-#define Log_PLATFORM_VERSION "SWAD 19.108.7 (2019-12-30)"
+#define Log_PLATFORM_VERSION "SWAD 19.108.8 (2019-12-30)"
#define CSS_FILE "swad19.101.5.css"
#define JS_FILE "swad19.91.1.js"
/*
@@ -500,8 +500,9 @@ ps2pdf source.ps destination.pdf
// TODO: Impedir la creación y edición de proyectos si no son editables.
// TODO: No se puede entrar con DNI '1' suponiendo que no tenga password ¿por qué?
- Version 19.10x: Dec 30, 2019 Map in country information. (? lines)
- Version 19.10x: Dec 30, 2019 Map in institution information. (? lines)
+ Version 19.10x: Dec 31, 2019 Map in country information. (? lines)
+ Version 19.10x: Dec 31, 2019 Map in institution information. (? lines)
+ Version 19.108.8: Dec 30, 2019 Code refactoring related to printing messages. (249700 lines)
Version 19.108.7: Dec 30, 2019 Code refactoring related to printing messages. (249674 lines)
Version 19.108.6: Dec 30, 2019 Code refactoring related to printing messages. (249717 lines)
Version 19.108.5: Dec 30, 2019 Code refactoring related to printing messages. (249712 lines)
diff --git a/swad_connected.c b/swad_connected.c
index 3f56a5c6..47135561 100644
--- a/swad_connected.c
+++ b/swad_connected.c
@@ -25,10 +25,11 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
+#define _GNU_SOURCE // For asprintf
#include // For maximum values
#include // For PATH_MAX
#include // For NULL
-#include // For fprintf
+#include // For asprintf
#include // For string functions
#include "swad_box.h"
@@ -83,6 +84,7 @@ void Con_ShowConnectedUsrs (void)
{
extern const char *Hlp_USERS_Connected;
extern const char *Txt_Connected_users;
+ char *Title;
/***** Contextual menu *****/
if (Gbl.Usrs.Me.Logged)
@@ -98,12 +100,13 @@ void Con_ShowConnectedUsrs (void)
/***** Begin box *****/
/* Current time */
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%s"
- "",
- Txt_Connected_users);
- Box_BoxBegin (NULL,Gbl.Title,Con_PutIconToUpdateConnected,
+ if (asprintf (&Title,"%s"
+ "",
+ Txt_Connected_users) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Box_BoxBegin (NULL,Title,Con_PutIconToUpdateConnected,
Hlp_USERS_Connected,Box_NOT_CLOSABLE);
+ free (Title);
Dat_WriteLocalDateHMSFromUTC ("connected_current_time",Gbl.StartExecutionTimeUTC,
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
false,false,true,0x7);
diff --git a/swad_course_config.c b/swad_course_config.c
index c1f3b2b5..2bde9d15 100644
--- a/swad_course_config.c
+++ b/swad_course_config.c
@@ -25,8 +25,10 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
+#define _GNU_SOURCE // For asprintf
#include // For boolean type
#include // For NULL
+#include // For asprintf
#include // For string functions
#include "swad_database.h"
@@ -440,6 +442,7 @@ static void CrsCfg_Indicators (void)
extern const char *Txt_of_PART_OF_A_TOTAL;
struct Ind_IndicatorsCrs Indicators;
int NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (Gbl.Hierarchy.Crs.CrsCod);
+ char *Title;
/***** Compute indicators ******/
Ind_ComputeAndStoreIndicatorsCrs (Gbl.Hierarchy.Crs.CrsCod,
@@ -454,16 +457,17 @@ static void CrsCfg_Indicators (void)
/* Data */
HTM_TD_Begin ("class=\"LB\"");
Frm_StartForm (ActReqStaCrs);
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%u %s %u",
- Indicators.NumIndicators,
- Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS);
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL);
- HTM_TxtF ("%s ",Gbl.Title);
+ if (asprintf (&Title,"%u %s %u",
+ Indicators.NumIndicators,
+ Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,"BT_LINK DAT",NULL);
+ HTM_TxtF ("%s ",Title);
Ico_PutIcon ((Indicators.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" :
"exclamation-triangle.svg",
- Gbl.Title,"ICO16x16");
+ Title,"ICO16x16");
HTM_BUTTON_End ();
+ free (Title);
Frm_EndForm ();
HTM_TD_End ();
diff --git a/swad_cryptography.c b/swad_cryptography.c
index 3fb88bae..8ad75b47 100644
--- a/swad_cryptography.c
+++ b/swad_cryptography.c
@@ -25,7 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
-#include // For fprintf
#include // For string functions
#include // For access, lstat, getpid, chdir, symlink
diff --git a/swad_database.c b/swad_database.c
index 937de420..328c3846 100644
--- a/swad_database.c
+++ b/swad_database.c
@@ -30,7 +30,7 @@
#include // To access MySQL databases
#include // For va_start, va_end
#include // For NULL
-#include // For FILE, fprintf, vasprintf
+#include // For FILE, vasprintf
#include // For free
#include "swad_config.h"
diff --git a/swad_degree_type.c b/swad_degree_type.c
index 91ce6202..030eaad4 100644
--- a/swad_degree_type.c
+++ b/swad_degree_type.c
@@ -28,7 +28,6 @@
#include // For isprint, isspace, etc.
#include // For boolean type
#include // For NULL
-#include // For fprintf, etc.
#include // For exit, system, calloc, free, etc.
#include // For string functions
#include // To access MySQL databases
diff --git a/swad_global.h b/swad_global.h
index 49af4849..5a6f6217 100644
--- a/swad_global.h
+++ b/swad_global.h
@@ -202,7 +202,6 @@ struct Globals
time_t StartExecutionTimeUTC;
struct DateTime Now;
struct Date Yesterday;
- char Title[Lay_MAX_BYTES_TITLE + 1]; // String for the help message in a link
unsigned RowEvenOdd; // To alternate row colors in listings
char *ColorRows[2];
const char *XMLPtr;
diff --git a/swad_layout.h b/swad_layout.h
index 46cc1918..b9e6177b 100644
--- a/swad_layout.h
+++ b/swad_layout.h
@@ -33,8 +33,6 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Lay_MAX_BYTES_TITLE (4096 - 1)
-
#define Lay_HIDE_BOTH_COLUMNS 0 // 00
#define Lay_SHOW_RIGHT_COLUMN 1 // 01
#define Lay_SHOW_LEFT_COLUMN 2 // 10
diff --git a/swad_menu.c b/swad_menu.c
index f8594fb0..081dcda1 100644
--- a/swad_menu.c
+++ b/swad_menu.c
@@ -25,8 +25,6 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
-#include // For fprintf, etc.
-
#include "swad_box.h"
#include "swad_database.h"
#include "swad_form.h"
diff --git a/swad_message.c b/swad_message.c
index 72e09bb1..5f541382 100644
--- a/swad_message.c
+++ b/swad_message.c
@@ -95,7 +95,7 @@ static unsigned long Msg_GetSentOrReceivedMsgs (long UsrCod,
const char *FilterFromToSubquery,
MYSQL_RES **mysql_res);
-static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs);
+static void Msg_SetNumMsgsStr (char **NumMsgsStr,unsigned NumUnreadMsgs);
static void Msg_PutIconsListMsgs (void);
static void Msg_PutHiddenParamsOneMsg (void);
@@ -1700,6 +1700,7 @@ static void Msg_ShowSentOrReceivedMessages (void)
MYSQL_ROW row;
unsigned long NumRow;
unsigned long NumRows;
+ char *NumMsgsStr;
unsigned long NumMsg = 0; // Initialized to avoid warning
unsigned NumUnreadMsgs = 0; // Initialized to avoid warning
struct Pagination Pagination;
@@ -1755,8 +1756,10 @@ static void Msg_ShowSentOrReceivedMessages (void)
Gbl.Msg.NumMsgs = (unsigned) NumRows;
/***** Begin box with messages *****/
- Box_BoxBegin ("97%",Msg_WriteNumMsgs (NumUnreadMsgs),Msg_PutIconsListMsgs,
+ Msg_SetNumMsgsStr (&NumMsgsStr,NumUnreadMsgs);
+ Box_BoxBegin ("97%",NumMsgsStr,Msg_PutIconsListMsgs,
Help[Gbl.Msg.TypeOfMessages],Box_NOT_CLOSABLE);
+ free (NumMsgsStr);
/***** Filter messages *****/
/* Begin box with filter */
@@ -2425,11 +2428,11 @@ unsigned Msg_GetNumMsgsReceived (Hie_Level_t Scope,Msg_Status_t MsgStatus)
}
/*****************************************************************************/
-/********* Write number of messages and number of unread messages ************/
+/***** Set string with number of messages and number of unread messages ******/
/*****************************************************************************/
-// Fill Gbl.Title
+// The string must be deallocated after calling this function
-static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs)
+static void Msg_SetNumMsgsStr (char **NumMsgsStr,unsigned NumUnreadMsgs)
{
extern const char *Txt_message_received;
extern const char *Txt_message_sent;
@@ -2444,45 +2447,55 @@ static char *Msg_WriteNumMsgs (unsigned NumUnreadMsgs)
if (Gbl.Msg.NumMsgs == 1)
{
if (NumUnreadMsgs)
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "1 %s, 1 %s",
- Txt_message_received,Txt_unread_MESSAGE);
+ {
+ if (asprintf (NumMsgsStr,"1 %s, 1 %s",
+ Txt_message_received,Txt_unread_MESSAGE) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
else
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "1 %s",
- Txt_message_received);
+ {
+ if (asprintf (NumMsgsStr,"1 %s",Txt_message_received) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
}
else
{
if (NumUnreadMsgs == 0)
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%u %s",
- Gbl.Msg.NumMsgs,Txt_messages_received);
+ {
+ if (asprintf (NumMsgsStr,"%u %s",
+ Gbl.Msg.NumMsgs,Txt_messages_received) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
else if (NumUnreadMsgs == 1)
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%u %s, 1 %s",
- Gbl.Msg.NumMsgs,Txt_messages_received,
- Txt_unread_MESSAGE);
+ {
+ if (asprintf (NumMsgsStr,"%u %s, 1 %s",
+ Gbl.Msg.NumMsgs,Txt_messages_received,
+ Txt_unread_MESSAGE) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
else
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%u %s, %u %s",
- Gbl.Msg.NumMsgs,Txt_messages_received,
- NumUnreadMsgs,Txt_unread_MESSAGES);
+ {
+ if (asprintf (NumMsgsStr,"%u %s, %u %s",
+ Gbl.Msg.NumMsgs,Txt_messages_received,
+ NumUnreadMsgs,Txt_unread_MESSAGES) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
}
break;
case Msg_MESSAGES_SENT:
if (Gbl.Msg.NumMsgs == 1)
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "1 %s",
- Txt_message_sent);
+ {
+ if (asprintf (NumMsgsStr,"1 %s",Txt_message_sent) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
else
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%u %s",
- Gbl.Msg.NumMsgs,Txt_messages_sent);
+ {
+ if (asprintf (NumMsgsStr,"%u %s",
+ Gbl.Msg.NumMsgs,Txt_messages_sent) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
break;
}
-
- return Gbl.Title;
}
/*****************************************************************************/
diff --git a/swad_pagination.c b/swad_pagination.c
index 9af2dcf8..9f581fdf 100644
--- a/swad_pagination.c
+++ b/swad_pagination.c
@@ -155,6 +155,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
extern const char *Txt_FORUM_Post_banned;
unsigned NumPage;
char *ClassLink;
+ char *Title;
/***** Link to page 1, including a text *****/
if (Subject)
@@ -243,12 +244,12 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted ();
break;
}
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- Txt_Page_X_of_Y,
- 1,Pagination->NumPags);
if (asprintf (&ClassLink,"BT_LINK LT %s",ClassTxt) < 0)
Lay_NotEnoughMemoryExit ();
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
+ if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
+ free (Title);
free (ClassLink);
}
else
@@ -357,12 +358,12 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted ();
break;
}
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- Txt_Page_X_of_Y,
- 1,Pagination->NumPags);
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
+ if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (1);
HTM_BUTTON_End ();
+ free (Title);
Frm_EndForm ();
if (Pagination->LeftPage > 2)
{
@@ -457,13 +458,13 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted ();
break;
}
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- Txt_Page_X_of_Y,
- Pagination->LeftPage,
- Pagination->NumPags);
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
+ if (asprintf (&Title,Txt_Page_X_of_Y,
+ Pagination->LeftPage,Pagination->NumPags) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (Pagination->LeftPage);
HTM_BUTTON_End ();
+ free (Title);
Frm_EndForm ();
if (Pagination->LeftPage < Pagination->StartPage - 1)
{
@@ -478,12 +479,11 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
NumPage <= Pagination->EndPage;
NumPage++)
{
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- Txt_Page_X_of_Y,
- NumPage,Pagination->NumPags);
+ if (asprintf (&Title,Txt_Page_X_of_Y,NumPage,Pagination->NumPags) < 0)
+ Lay_NotEnoughMemoryExit ();
if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage)
{
- HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR %s\"",Gbl.Title,ClassTxt);
+ HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR %s\"",Title,ClassTxt);
HTM_Unsigned (NumPage);
HTM_SPAN_End ();
}
@@ -570,11 +570,12 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted ();
break;
}
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
+ HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (NumPage);
HTM_BUTTON_End ();
Frm_EndForm ();
}
+ free (Title);
}
/***** Posible link to page right *****/
@@ -668,12 +669,13 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted ();
break;
}
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- Txt_Page_X_of_Y,
- Pagination->RightPage,Pagination->NumPags);
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
+ if (asprintf (&Title,Txt_Page_X_of_Y,
+ Pagination->RightPage,Pagination->NumPags) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (Pagination->RightPage);
HTM_BUTTON_End ();
+ free (Title);
Frm_EndForm ();
}
@@ -767,12 +769,13 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
Usr_PutParamOtherUsrCodEncrypted ();
break;
}
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- Txt_Page_X_of_Y,
- Pagination->NumPags,Pagination->NumPags);
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
+ if (asprintf (&Title,Txt_Page_X_of_Y,
+ Pagination->NumPags,Pagination->NumPags) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
HTM_Unsigned (Pagination->NumPags);
HTM_BUTTON_End ();
+ free (Title);
Frm_EndForm ();
}
diff --git a/swad_profile.c b/swad_profile.c
index ce6f4fd7..a507e2c1 100644
--- a/swad_profile.c
+++ b/swad_profile.c
@@ -25,7 +25,9 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
+#define _GNU_SOURCE // For asprintf
#include // For NULL
+#include // For asprintf
#include // For string functions
#include "swad_box.h"
@@ -943,17 +945,16 @@ static void Prf_ShowRanking (unsigned long Rank,unsigned long NumUsrs)
{
extern const char *The_ClassFormLinkOutBox[The_NUM_THEMES];
extern const char *Txt_of_PART_OF_A_TOTAL;
-
- /***** Part of a total and end container *****/
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "#%lu %s %lu",
- Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs);
+ char *Title;
/***** Rank in form to go to ranking *****/
Frm_StartForm (ActSeeUseGbl);
Sco_PutParamScope ("ScopeSta",Hie_SYS);
Par_PutHiddenParamUnsigned (NULL,"FigureType",(unsigned) Fig_USERS_RANKING);
- HTM_BUTTON_SUBMIT_Begin (Gbl.Title,The_ClassFormLinkOutBox[Gbl.Prefs.Theme],NULL);
+ if (asprintf (&Title,"#%lu %s %lu",Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs) < 0)
+ Lay_NotEnoughMemoryExit ();
+ HTM_BUTTON_SUBMIT_Begin (Title,The_ClassFormLinkOutBox[Gbl.Prefs.Theme],NULL);
+ free (Title);
HTM_TxtF ("#%lu",Rank);
HTM_BUTTON_End ();
Frm_EndForm ();
diff --git a/swad_project.c b/swad_project.c
index b1bb1131..9005962d 100644
--- a/swad_project.c
+++ b/swad_project.c
@@ -2275,7 +2275,7 @@ static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject)
[Prj_ROLE_TUT] = ActAddTutPrj, // Tutor
[Prj_ROLE_EVL] = ActAddEvlPrj, // Evaluator
};
- char TxtButton[Lay_MAX_BYTES_TITLE + 1];
+ char *TxtButton;
/***** Get parameters *****/
Prj_GetParams ();
@@ -2283,15 +2283,16 @@ static void Prj_ReqAddUsrs (Prj_RoleInProject_t RoleInProject)
Lay_ShowErrorAndExit ("Code of project is missing.");
/***** Put form to select users *****/
- snprintf (TxtButton,sizeof (TxtButton),
- Txt_Add_USERS,
- Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]);
+ if (asprintf (&TxtButton,Txt_Add_USERS,
+ Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]) < 0)
+ Lay_NotEnoughMemoryExit ();
Usr_PutFormToSelectUsrsToGoToAct (&Prj_MembersToAdd,
ActionAddUsr[RoleInProject],Prj_PutCurrentParams,
TxtButton,
Hlp_ASSESSMENT_Projects_add_user,
TxtButton,
false); // Do not put form with date range
+ free (TxtButton);
/***** Put a form to create/edit project *****/
Prj_RequestCreatOrEditPrj (Gbl.Prjs.PrjCod);
diff --git a/swad_search.c b/swad_search.c
index d5a7f1b6..2ec2af9c 100644
--- a/swad_search.c
+++ b/swad_search.c
@@ -25,7 +25,6 @@
/*********************************** Headers *********************************/
/*****************************************************************************/
-#include // For fprintf...
#include // For string functions...
#include "swad_box.h"
diff --git a/swad_setting.c b/swad_setting.c
index 37690868..b392acca 100644
--- a/swad_setting.c
+++ b/swad_setting.c
@@ -27,7 +27,6 @@
#include // For boolean type
#include // For NULL
-#include // For fprintf, etc.
#include
#include "swad_box.h"
diff --git a/swad_survey.c b/swad_survey.c
index fefab82f..2d6fb08c 100644
--- a/swad_survey.c
+++ b/swad_survey.c
@@ -2606,6 +2606,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
MYSQL_ROW row;
unsigned NumAns;
unsigned NumAnswers = 0;
+ char *Title;
Svy_AnswerType_t AnsType;
if (Gbl.Action.Act == ActEdiOneSvyQst) // If no receiving the question, but editing a new or existing question
@@ -2664,11 +2665,11 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
Svy_CurrentSvyCod = SvyCod;
Svy_CurrentQstCod = SvyQst->QstCod;
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%s %u",
- Txt_Question,SvyQst->QstInd + 1); // Question index may be 0, 1, 2, 3,...
- Box_BoxBegin (NULL,Gbl.Title,Svy_PutIconToRemoveOneQst,
+ if (asprintf (&Title,"%s %u",Txt_Question,SvyQst->QstInd + 1) < 0) // Question index may be 0, 1, 2, 3,...
+ Lay_NotEnoughMemoryExit ();
+ Box_BoxBegin (NULL,Title,Svy_PutIconToRemoveOneQst,
NULL,Box_NOT_CLOSABLE);
+ free (Title);
}
else
Box_BoxBegin (NULL,Txt_New_question,NULL,
@@ -3473,18 +3474,23 @@ static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
{
extern const char *Txt_of_PART_OF_A_TOTAL;
unsigned BarWidth = 0;
+ char *Title;
- /***** String with the number of users *****/
+ /***** Build string with the number of users *****/
if (MaxUsrs)
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%u (%u%% %s %u)",
- NumUsrs,
- (unsigned) ((((double) NumUsrs * 100.0) / (double) MaxUsrs) + 0.5),
- Txt_of_PART_OF_A_TOTAL,MaxUsrs);
+ {
+ if (asprintf (&Title,"%u (%u%% %s %u)",
+ NumUsrs,
+ (unsigned) ((((double) NumUsrs * 100.0) / (double) MaxUsrs) + 0.5),
+ Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
else
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "0 (0%% %s %u)",
- Txt_of_PART_OF_A_TOTAL,MaxUsrs);
+ {
+ if (asprintf (&Title,"0 (0%% %s %u)",
+ Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
+ Lay_NotEnoughMemoryExit ();
+ }
HTM_TD_Begin ("class=\"DAT LT\" style=\"width:%upx;\"",Svy_MAX_BAR_WIDTH + 125);
@@ -3494,11 +3500,14 @@ static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
(double) MaxUsrs) + 0.5);
if (BarWidth < 2)
BarWidth = 2;
- HTM_IMG (Cfg_URL_ICON_PUBLIC,"o1x1.png",Gbl.Title,
+ HTM_IMG (Cfg_URL_ICON_PUBLIC,"o1x1.png",Title,
"class=\"LT\" style=\"width:%upx; height:20px;\"",BarWidth);
/***** Write the number of users *****/
- HTM_TxtF (" %s",Gbl.Title);
+ HTM_TxtF (" %s",Title);
+
+ /***** Free string with the number of users *****/
+ free (Title);
HTM_TD_End ();
}
diff --git a/swad_test.c b/swad_test.c
index ec9f50fb..1afa7e3c 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -31,7 +31,7 @@
#include // To access MySQL databases
#include // For boolean type
#include // For NULL
-#include // For fprintf, asprintf, etc.
+#include // For asprintf
#include // For exit, system, malloc, free, etc
#include // For string functions
#include // For mkdir
@@ -5085,6 +5085,7 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
bool DisplayRightColumn;
char StrTagTxt[6 + Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char StrInteger[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
+ char *Title;
/***** Begin box *****/
if (Gbl.Test.QstCod > 0) // The question already has assigned a code
@@ -5361,29 +5362,29 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1],
HTM_TxtF ("%c)",'a' + (char) NumOpt);
/* Icon to expand (show the answer) */
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%s %c)",
- Txt_Expand,'a' + (char) NumOpt);
HTM_A_Begin ("href=\"\" id=\"exp_%u\"%s"
" onclick=\"toggleAnswer('%u');return false;\"",
NumOpt,
DisplayRightColumn ? " style=\"display:none;\"" : // Answer does have content ==> Hide icon
"",
NumOpt);
- Ico_PutIcon ("caret-right.svg",Gbl.Title,"ICO16x16");
+ if (asprintf (&Title,"%s %c)",Txt_Expand,'a' + (char) NumOpt) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Ico_PutIcon ("caret-right.svg",Title,"ICO16x16");
+ free (Title);
HTM_A_End ();
/* Icon to contract (hide the answer) */
- snprintf (Gbl.Title,sizeof (Gbl.Title),
- "%s %c)",
- Txt_Contract,'a' + (char) NumOpt);
HTM_A_Begin ("href=\"\" id=\"con_%u\"%s"
" onclick=\"toggleAnswer(%u);return false;\"",
NumOpt,
DisplayRightColumn ? "" :
" style=\"display:none;\"", // Answer does not have content ==> Hide icon
NumOpt);
- Ico_PutIcon ("caret-down.svg",Gbl.Title,"ICO16x16");
+ if (asprintf (&Title,"%s %c)",Txt_Contract,'a' + (char) NumOpt) < 0)
+ Lay_NotEnoughMemoryExit ();
+ Ico_PutIcon ("caret-down.svg",Title,"ICO16x16");
+ free (Title);
HTM_A_End ();
HTM_TD_End ();
diff --git a/swad_theme.c b/swad_theme.c
index 540f0e2d..9eb5e05d 100644
--- a/swad_theme.c
+++ b/swad_theme.c
@@ -25,7 +25,6 @@
/********************************** Headers **********************************/
/*****************************************************************************/
-#include // For fprintf, etc.
#include
#include "swad_box.h"