From 7431524e5b8f770b822ca771e9e5c4beb9d50e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 26 Jan 2016 12:14:16 +0100 Subject: [PATCH] Version 15.130.2 --- swad_changelog.h | 3 ++- swad_parameter.c | 3 +++ swad_string.c | 53 +++++++++++++++++++++++++++------------------- swad_web_service.c | 10 +++++---- 4 files changed, 42 insertions(+), 27 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 924527d5f..d39c626ab 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -121,13 +121,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.130.1 (2016-01-26)" +#define Log_PLATFORM_VERSION "SWAD 15.130.2 (2016-01-26)" #define CSS_FILE "swad15.121.7.css" #define JS_FILE "swad15.121.7.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.130.2: Jan 26, 2016 Oprimization in the function that insert links in text. (194928 lines) Version 15.130.1: Jan 26, 2016 Fixed bug when mentioning an user who does not exist. (194914 lines) Version 15.130: Jan 26, 2016 Do not notify new social notes. (194913 lines) 22 changes necessary in database: diff --git a/swad_parameter.c b/swad_parameter.c index 1e7e2e1b7..4166a1adb 100644 --- a/swad_parameter.c +++ b/swad_parameter.c @@ -32,6 +32,9 @@ #include "swad_action.h" #include "swad_config.h" + +#include "swad_database.h" // TODO: remove when debug ends + #include "swad_global.h" #include "swad_parameter.h" #include "swad_password.h" diff --git a/swad_string.c b/swad_string.c index cae20aba7..72b812f04 100644 --- a/swad_string.c +++ b/swad_string.c @@ -83,6 +83,20 @@ Insertion example: The web site of @rms is https://stallman.org/ The web site of @rms is https://stallman.org/ */ + +/* + +
+ + + +@acanas + +
+ +*/ + #define ANCHOR_1_URL "" #define ANCHOR_3 "" @@ -118,12 +132,13 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre char *PtrStart; char *PtrEnd; size_t NumActualBytes; // Actual length of the URL/nickname - size_t AnchorsLengthUntilHere; + size_t AddedLengthUntilHere; } Links[MAX_LINKS]; - size_t LinksTotalLength = 0; + size_t LengthVisibleLink; size_t Length; size_t i; - size_t NumChars1,NumChars2; + size_t NumChars1; + size_t NumChars2; size_t NumBytesToCopy; size_t NumBytesToShow; // Length of the link displayed on screen (may be shorter than actual length) char LimitedURL[MAX_BYTES_LIMITED_URL+1]; @@ -215,7 +230,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre /* Calculate length of this URL */ Links[NumLinks].NumActualBytes = (size_t) (Links[NumLinks].PtrEnd + 1 - Links[NumLinks].PtrStart); if (Links[NumLinks].NumActualBytes <= MaxCharsURLOnScreen) - LinksTotalLength += Links[NumLinks].NumActualBytes; + LengthVisibleLink = Links[NumLinks].NumActualBytes; else // If URL is too long to be displayed ==> short it { /* Make a copy of this URL */ @@ -225,13 +240,13 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre LimitedURL[NumBytesToCopy] = '\0'; /* Limit the number of characters on screen of the copy, and calculate its length in bytes */ - LinksTotalLength += Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); + LengthVisibleLink = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); } if (NumLinks == 0) - Links[NumLinks].AnchorsLengthUntilHere = AnchorURLTotalLength; + Links[NumLinks].AddedLengthUntilHere = AnchorURLTotalLength + LengthVisibleLink; else - Links[NumLinks].AnchorsLengthUntilHere = Links[NumLinks - 1].AnchorsLengthUntilHere + - AnchorURLTotalLength; + Links[NumLinks].AddedLengthUntilHere = Links[NumLinks - 1].AddedLengthUntilHere + + AnchorURLTotalLength + LengthVisibleLink; /* Increment number of found nicknames and links */ NumURLs++; @@ -270,12 +285,12 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre if (IsNickname) { - LinksTotalLength += Links[NumLinks].NumActualBytes; + LengthVisibleLink = Links[NumLinks].NumActualBytes; if (NumLinks == 0) - Links[NumLinks].AnchorsLengthUntilHere = AnchorNickTotalLength; + Links[NumLinks].AddedLengthUntilHere = AnchorNickTotalLength + LengthVisibleLink; else - Links[NumLinks].AnchorsLengthUntilHere = Links[NumLinks - 1].AnchorsLengthUntilHere + - AnchorNickTotalLength; + Links[NumLinks].AddedLengthUntilHere = Links[NumLinks - 1].AddedLengthUntilHere + + AnchorNickTotalLength + LengthVisibleLink; /* Increment number of found nicknames and links */ NumNicks++; @@ -293,10 +308,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre { /***** Insert links from end to start of text, only if there is enough space available in text *****/ - TxtLengthWithInsertedAnchors = TxtLength + - LinksTotalLength + - AnchorURLTotalLength * NumURLs + - AnchorNickTotalLength * NumNicks; + TxtLengthWithInsertedAnchors = TxtLength + Links[NumLinks - 1].AddedLengthUntilHere; if (TxtLengthWithInsertedAnchors <= MaxLength) for (NumLink = NumLinks - 1; NumLink >= 0; @@ -309,7 +321,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre for (i = 0, PtrSrc = (NumLink == NumLinks - 1) ? Txt + TxtLength : Links[NumLink + 1].PtrStart - 1, - PtrDst = PtrSrc + LinksTotalLength + Links[NumLink].AnchorsLengthUntilHere, + PtrDst = PtrSrc + Links[NumLink].AddedLengthUntilHere, Length = PtrSrc - Links[NumLink].PtrEnd; i < Length; i++) @@ -326,7 +338,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre Links[NumLink].NumActualBytes <= MaxCharsURLOnScreen) { NumBytesToShow = Links[NumLink].NumActualBytes; - PtrSrc = Links[NumLink].PtrEnd; // PtrSrc must point to end of complete URL or nickname + PtrSrc = Links[NumLink].PtrEnd; // PtrSrc must point to end of complete nickname } else // If URL is too long to be displayed ==> short it { @@ -339,8 +351,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre /* Limit the length of the copy */ NumBytesToShow = Str_LimitLengthHTMLStr (LimitedURL,MaxCharsURLOnScreen); - /* PtrSrc must point to end of limited URL */ - PtrSrc = LimitedURL + NumBytesToShow - 1; + PtrSrc = LimitedURL + NumBytesToShow - 1; // PtrSrc must point to end of limited URL } for (i = 0; i < NumBytesToShow; @@ -386,8 +397,6 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre i < Length; i++) *PtrDst-- = *PtrSrc--; - - LinksTotalLength -= NumBytesToShow; } } } diff --git a/swad_web_service.c b/swad_web_service.c index ef8a48aec..9e822b7d7 100644 --- a/swad_web_service.c +++ b/swad_web_service.c @@ -3684,7 +3684,7 @@ int swad__getTrivialQuestion (struct soap *soap, /***** Loop over recipients' nicknames building query *****/ DegreesStr[0] = '\0'; Ptr = degrees; - +/* if (Gbl.Usrs.Me.UsrDat.UsrCod == 19543) { char QueryDebug[512*1024]; @@ -3692,7 +3692,7 @@ int swad__getTrivialQuestion (struct soap *soap, sprintf (QueryDebug,"INSERT INTO debug (DebugTime,Txt) VALUES (NOW(),'degrees = %s')",degrees); DB_QueryINSERT (QueryDebug,"Error inserting in debug table"); } - +*/ while (*Ptr) { /* Find next string in text until comma (leading and trailing spaces are removed) */ @@ -3757,6 +3757,7 @@ int swad__getTrivialQuestion (struct soap *soap, if (NumRows == 1) // Question found { +/* if (Gbl.Usrs.Me.UsrDat.UsrCod == 19543) { char QueryDebug[512*1024]; @@ -3764,7 +3765,7 @@ int swad__getTrivialQuestion (struct soap *soap, sprintf (QueryDebug,"INSERT INTO debug (DebugTime,Txt) VALUES (NOW(),'Una pregunta devuelta')"); DB_QueryINSERT (QueryDebug,"Error inserting in debug table"); } - +*/ /* Get next question */ row = mysql_fetch_row (mysql_res); @@ -3794,6 +3795,7 @@ int swad__getTrivialQuestion (struct soap *soap, } else // Empty question { +/* if (Gbl.Usrs.Me.UsrDat.UsrCod == 19543) { char QueryDebug[512*1024]; @@ -3801,7 +3803,7 @@ int swad__getTrivialQuestion (struct soap *soap, sprintf (QueryDebug,"INSERT INTO debug (DebugTime,Txt) VALUES (NOW(),'Ninguna pregunta devuelta')"); DB_QueryINSERT (QueryDebug,"Error inserting in debug table"); } - +*/ /* Question code (row[0]) */ QstCod = -1L; getTrivialQuestionOut->question.questionCode = -1;