From bb29e96ada5ff15db2d5b1765aaff40a97271bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 30 Dec 2019 20:41:40 +0100 Subject: [PATCH] Version19.108.6 --- swad_centre.c | 11 +++++------ swad_changelog.h | 3 ++- swad_country.c | 11 +++++------ swad_course.c | 11 +++++------ swad_degree.c | 11 +++++------ swad_file_browser.c | 11 +++++------ swad_institution.c | 11 +++++------ swad_match.c | 17 ++++++++++------- swad_string.c | 11 +++++++++++ swad_string.h | 1 + swad_user.c | 16 +++++++--------- 11 files changed, 61 insertions(+), 53 deletions(-) diff --git a/swad_centre.c b/swad_centre.c index d4c12221..055d07a4 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -2003,12 +2003,11 @@ void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs) { /***** Begin box and table *****/ /* Number of centres found */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumCtrs,(NumCtrs == 1) ? Txt_centre : - Txt_centres); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumCtrs, + (NumCtrs == 1) ? Txt_centre : + Txt_centres), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Write heading *****/ Ctr_PutHeadCentresForSeeing (false); // Order not selectable diff --git a/swad_changelog.h b/swad_changelog.h index d5c281c0..2caf91b0 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.5 (2019-12-30)" +#define Log_PLATFORM_VERSION "SWAD 19.108.6 (2019-12-30)" #define CSS_FILE "swad19.101.5.css" #define JS_FILE "swad19.91.1.js" /* @@ -502,6 +502,7 @@ ps2pdf source.ps destination.pdf Version 19.10x: Dec 30, 2019 Map in country information. (? lines) Version 19.10x: Dec 30, 2019 Map in institution information. (? 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) Version 19.108.4: Dec 30, 2019 Code refactoring related to printing messages. (249709 lines) Version 19.108.3: Dec 30, 2019 Code refactoring related to printing messages. (249725 lines) diff --git a/swad_country.c b/swad_country.c index dc81218a..6634a5db 100644 --- a/swad_country.c +++ b/swad_country.c @@ -2044,12 +2044,11 @@ void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys) { /***** Begin box and table *****/ /* Number of countries found */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumCtys,NumCtys == 1 ? Txt_country : - Txt_countries); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumCtys, + NumCtys == 1 ? Txt_country : + Txt_countries), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Write heading *****/ Cty_PutHeadCountriesForSeeing (false); // Order not selectable diff --git a/swad_course.c b/swad_course.c index bea9ce12..910dd337 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2505,12 +2505,11 @@ void Crs_ListCrssFound (MYSQL_RES **mysql_res,unsigned NumCrss) { /***** Begin box and table *****/ /* Number of courses found */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumCrss,(NumCrss == 1) ? Txt_course : - Txt_courses); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumCrss, + (NumCrss == 1) ? Txt_course : + Txt_courses), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Heading row *****/ HTM_TR_Begin (NULL); diff --git a/swad_degree.c b/swad_degree.c index 973a5cd4..c96dc7dd 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1957,12 +1957,11 @@ void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumDegs) { /***** Begin box and table *****/ /* Number of degrees found */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumDegs,(NumDegs == 1) ? Txt_degree : - Txt_degrees); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumDegs, + (NumDegs == 1) ? Txt_degree : + Txt_degrees), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Write heading *****/ Deg_PutHeadDegreesForSeeing (); diff --git a/swad_file_browser.c b/swad_file_browser.c index 2aadab83..6178f232 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -11807,12 +11807,11 @@ void Brw_ListDocsFound (MYSQL_RES **mysql_res,unsigned long NumDocs, { /***** Begin box and table *****/ /* Number of documents found */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%lu %s", - NumDocs,(NumDocs == 1) ? TitleSingular : - TitlePlural); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumDocs, + (NumDocs == 1) ? TitleSingular : + TitlePlural), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Write heading *****/ HTM_TR_Begin (NULL); diff --git a/swad_institution.c b/swad_institution.c index 40600da7..ab948051 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1968,12 +1968,11 @@ void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss) { /***** Begin box and table *****/ /* Number of institutions found */ - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumInss,NumInss == 1 ? Txt_institution : - Txt_institutions); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumInss, + NumInss == 1 ? Txt_institution : + Txt_institutions), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Write heading *****/ Ins_PutHeadInstitutionsForSeeing (false); // Order not selectable diff --git a/swad_match.c b/swad_match.c index d46b6e41..1c81d12c 100644 --- a/swad_match.c +++ b/swad_match.c @@ -2696,24 +2696,27 @@ static void Mch_ShowFormColumns (const struct Match *Match) NumCols <= Mch_MAX_COLS; NumCols++) { + /* Begin container for this option */ HTM_DIV_Begin ("class=\"%s\"", (Match->Status.NumCols == NumCols) ? "PREF_ON" : "PREF_OFF"); - /***** Begin form *****/ + /* Begin form */ Frm_StartForm (ActChgNumColMch); Mch_PutParamMchCod (Match->MchCod); // Current match being played Mch_PutParamNumCols (NumCols); // Number of columns - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumCols,NumCols == 1 ? Txt_column : - Txt_columns); - Ico_PutSettingIconLink (NumColsIcon[NumCols],Gbl.Title); + /* Number of columns */ + Ico_PutSettingIconLink (NumColsIcon[NumCols], + Str_BuildMsgLongStr ((long) NumCols, + NumCols == 1 ? Txt_column : + Txt_columns)); + Str_FreeMsg (); - /***** End form *****/ + /* End form */ Frm_EndForm (); + /* End container for this option */ HTM_DIV_End (); } diff --git a/swad_string.c b/swad_string.c index a90a2046..8dc55870 100644 --- a/swad_string.c +++ b/swad_string.c @@ -2953,6 +2953,17 @@ char *Str_BuildMsgLong (const char *fmt,long Num) return Str_Msg; } +// Str_FreeMsg() must be called after calling this function + +char *Str_BuildMsgLongStr (long Num,const char *Str) + { + Str_FreeMsg (); + if (asprintf (&Str_Msg,"%ld %s",Num,Str) < 0) + Lay_NotEnoughMemoryExit (); + + return Str_Msg; + } + void Str_FreeMsg (void) { if (Str_Msg != NULL) diff --git a/swad_string.h b/swad_string.h index aac29ba7..777722c3 100644 --- a/swad_string.h +++ b/swad_string.h @@ -138,6 +138,7 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize); char *Str_BuildMsgStr (const char *fmt,const char *Str); char *Str_BuildMsgLong (const char *fmt,long Num); +char *Str_BuildMsgLongStr (long Num,const char *Str); void Str_FreeMsg (void); #endif diff --git a/swad_user.c b/swad_user.c index df47f38f..460f923b 100644 --- a/swad_user.c +++ b/swad_user.c @@ -7390,15 +7390,13 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role, /***** Begin box and table *****/ /* Number of users found */ Sex = Usr_GetSexOfUsrsLst (Role); - snprintf (Gbl.Title,sizeof (Gbl.Title), - "%u %s", - NumUsrs, - (Role == Rol_UNK) ? ((NumUsrs == 1) ? Txt_user[Sex] : - Txt_users[Sex]) : - ((NumUsrs == 1) ? Txt_ROLES_SINGUL_abc[Role][Sex] : - Txt_ROLES_PLURAL_abc[Role][Sex])); - Box_BoxTableBegin (NULL,Gbl.Title,NULL, - NULL,Box_NOT_CLOSABLE,2); + Box_BoxTableBegin (NULL,Str_BuildMsgLongStr ((long) NumUsrs, + (Role == Rol_UNK) ? ((NumUsrs == 1) ? Txt_user[Sex] : + Txt_users[Sex]) : + ((NumUsrs == 1) ? Txt_ROLES_SINGUL_abc[Role][Sex] : + Txt_ROLES_PLURAL_abc[Role][Sex])), + NULL,NULL,Box_NOT_CLOSABLE,2); + Str_FreeMsg (); /***** Heading row with column names *****/ Gbl.Usrs.Listing.WithPhotos = true;