From fc52b5d6442e8248c81e251ccc5701faa5393728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 31 Mar 2016 20:09:47 +0200 Subject: [PATCH] Version 15.169.5 --- swad_changelog.h | 3 ++- swad_info.c | 6 ++++-- swad_parameter.c | 18 +++++++++++++----- swad_parameter.h | 3 ++- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 051dcf45..5e72edc2 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -138,13 +138,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.169.4 (2016-03-31)" +#define Log_PLATFORM_VERSION "SWAD 15.169.5 (2016-03-31)" #define CSS_FILE "swad15.165.5.css" #define JS_FILE "swad15.131.3.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 15.169.5: Mar 31, 2016 Code refactoring in function to get a parameter. (197292 lines) Version 15.169.4: Mar 31, 2016 Code refactoring in list of parameters. (197280 lines) Version 15.169.3: Mar 31, 2016 Code refactoring in list of parameters. (197271 lines) Version 15.169.2: Mar 31, 2016 Code refactoring in list of parameters. Not finished. (197298 lines) diff --git a/swad_info.c b/swad_info.c index d9dc7d9b..27b85bd3 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1885,7 +1885,8 @@ void Inf_RecAndChangePlainTxtInfo (void) Gbl.CurrentCrs.Info.Type = Inf_AsignInfoType (); /***** Get text with course information from form *****/ - Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT); + Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, + Cns_MAX_BYTES_LONG_TEXT,NULL); strcpy (Txt_MarkdownFormat,Txt_HTMLFormat); Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) @@ -1919,7 +1920,8 @@ void Inf_RecAndChangeRichTxtInfo (void) Gbl.CurrentCrs.Info.Type = Inf_AsignInfoType (); /***** Get text with course information from form *****/ - Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT); + Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, + Cns_MAX_BYTES_LONG_TEXT,NULL); strcpy (Txt_MarkdownFormat,Txt_HTMLFormat); Str_ChangeFormat (Str_FROM_FORM,Str_TO_HTML, Txt_HTMLFormat,Cns_MAX_BYTES_LONG_TEXT,true); // Store in HTML format (not rigorous) diff --git a/swad_parameter.c b/swad_parameter.c index 574565f7..df456291 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -521,9 +521,11 @@ void Par_FreeParams (void) /************************* Get the value of a parameter **********************/ /*****************************************************************************/ // Return the number of parameters found +// If ParamPtr is not null, on return it will point to the first ocurrence in list of parameters unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, - char *ParamValue,size_t MaxBytes) + char *ParamValue,size_t MaxBytes, + struct Param *ParamPtr) // NULL is not used { size_t BytesAlreadyCopied = 0; unsigned i; @@ -578,9 +580,15 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, if (ParamFound) { - /***** Add separator when param multiple *****/ - if (NumTimes) // Not the first ocurrence of this parameter + if (NumTimes == 0) // The first ocurrence of this parameter { + /***** Get the first ocurrence of this parameter in list *****/ + if (ParamPtr) + ParamPtr = Param; + } + else // Not the first ocurrence of this parameter + { + /***** Add separator when param multiple *****/ /* Check if there is space to copy separator */ if (BytesAlreadyCopied + 1 > MaxBytes) { @@ -930,7 +938,7 @@ unsigned Par_GetParToHTML (const char *ParamName,char *ParamValue,size_t MaxByte unsigned Par_GetParMultiToText (const char *ParamName,char *ParamValue,size_t MaxBytes) { unsigned NumTimes = Par_GetParameter (Par_PARAM_MULTIPLE,ParamName, - ParamValue,MaxBytes); + ParamValue,MaxBytes,NULL); Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT, ParamValue,MaxBytes,true); return NumTimes; @@ -945,7 +953,7 @@ unsigned Par_GetParAndChangeFormat (const char *ParamName,char *ParamValue,size_ Str_ChangeTo_t ChangeTo,bool RemoveLeadingAndTrailingSpaces) { unsigned NumTimes = Par_GetParameter (Par_PARAM_SINGLE,ParamName, - ParamValue,MaxBytes); + ParamValue,MaxBytes,NULL); Str_ChangeFormat (Str_FROM_FORM,ChangeTo, ParamValue,MaxBytes,RemoveLeadingAndTrailingSpaces); return NumTimes; diff --git a/swad_parameter.h b/swad_parameter.h index bf0f995f..d38d90a4 100644 --- a/swad_parameter.h +++ b/swad_parameter.h @@ -66,7 +66,8 @@ bool Par_GetQueryString (void); void Par_CreateListOfParams (void); void Par_FreeParams (void); unsigned Par_GetParameter (tParamType ParamType,const char *ParamName, - char *ParamValue,size_t MaxBytes); + char *ParamValue,size_t MaxBytes, + struct Param *ParamPtr); void Par_GetMainParameters (void);